uf = 37568.84; $tipoEstadoPago = $this->getMockBuilder(Model\Venta\TipoEstadoPago::class)->disableOriginalConstructor()->getMock(); $tipoEstadoPago->id = 1; $tipoEstadoPago->descripcion = 'depositado'; $estadoPago = $this->getMockBuilder(Model\Venta\EstadoPago::class)->disableOriginalConstructor()->getMock(); $estadoPago->id = 1; $estadoPago->tipoEstadoPago = $tipoEstadoPago; $estadoPago->fecha = $fecha; $this->pago = $this->getMockBuilder(Model\Venta\Pago::class)->disableOriginalConstructor()->getMock(); $this->pago->id = 1; $this->pago->fecha = $fecha; $this->pago->uf = $this->uf; $this->pago->currentEstado = $estadoPago; $this->pagoRepository = $this->getMockBuilder(Repository\Venta\Pago::class)->disableOriginalConstructor()->getMock(); $this->pagoRepository->method('fetchById')->willReturn($this->pago); $this->pagoRepository->method('edit')->willReturnCallback(function() { $this->pago->uf = $this->uf; return $this->pago; }); $this->estadoPagoRepository = $this->getMockBuilder(Repository\Venta\EstadoPago::class)->disableOriginalConstructor()->getMock(); $this->estadoPagoRepository->method('fetchCurrentByPago')->with($this->pago->id)->willReturn($estadoPago); $this->tipoEstadoPagoRepository = $this->getMockBuilder(Repository\Venta\TipoEstadoPago::class)->disableOriginalConstructor()->getMock(); $this->ufService = $this->getMockBuilder(Service\UF::class)->disableOriginalConstructor()->getMock(); $this->ufService->method('get')->with($fecha)->willReturn($this->uf); $this->valorService = $this->getMockBuilder(Service\Valor::class)->disableOriginalConstructor()->getMock(); $this->queueService = $this->getMockBuilder(Service\Queue::class)->disableOriginalConstructor()->getMock(); } public function testUpdateUF(): void { $this->pago->uf = null; $pagoService = new Service\Venta\Pago( $this->pagoRepository, $this->estadoPagoRepository, $this->tipoEstadoPagoRepository, $this->ufService, $this->valorService, $this->queueService ); $status = $pagoService->updateUF($this->pago->id); $pago = $pagoService->getById($this->pago->id); $this->assertTrue($status); $this->assertEquals($pago->uf, $this->uf); } }