Error in `ncell(r1)`: could not find function "ncell"

test_that("mosaic_reproject_resample works with synthetic rasters", {
dir.create(tmp_dir, recursive = TRUE, showWarnings = FALSE)
# Crear dos raster tiles sintéticos con CRS proyectado (EPSG:3035)
make_raster_tile <- function(name, offset_x = 0) {
r1 <- terra::rast(nrows = 10, ncols = 10,
xmin = offset_x, xmax = offset_x + 1000,
terra::values(r1) <- runif(ncell(r1), 0, 100)      # RBR
terra::values(r2) <- sample(150:250, ncell(r2), replace = TRUE)  # DOY
out_path <- file.path(tmp_dir, paste0(name, ".tif"))
# ✅ Cambiar esta línea para que admita -9999 como nodata
terra::writeRaster(r_stack, out_path, overwrite = TRUE, datatype = "FLT4S")
raster1 <- make_raster_tile("tile1", offset_x = 0)
raster2 <- make_raster_tile("tile2", offset_x = 1000)
# Crear shapefile de máscara que cubre ambos raster tiles
mask_sf <- sf::st_sf(geometry = sf::st_sfc(mask_poly), crs = 3035)
sf::st_write(mask_sf, mask_path, quiet = TRUE)
# Ejecutar la función con resolución adecuada (e.g., 100 m)

"mosaic_reproject_resample works with synthetic rasters"

mosaic_reproject_resample works with synthetic rasters