client = new Client(['base_uri' => 'https://www.sii.cl/valores_y_fechas/']); $this->pdo = $this->getMockBuilder(PDO::class) ->disableOriginalConstructor()->getMock(); $this->pdo->method('beginTransaction')->willReturn(true); $this->pdo->method('commit')->willReturn(true); #$this->pdo->method('rollBack')->willReturn(null); $this->statement = $this->getMockBuilder(PDOStatement::class)->getMock(); $this->statement->method('fetchAll')->willReturn([]); $this->connection = $this->getMockBuilder(Define\Connection::class) ->disableOriginalConstructor()->getMock(); $this->connection->method('getPDO')->willReturn($this->pdo); $this->connection->method('query')->willReturn($this->statement); $this->connection->method('execute')->willReturn($this->statement); $this->ufRepository = $this->getMockBuilder(Repository\UF::class) ->disableOriginalConstructor()->getMock(); $this->ufRepository->method('getConnection')->willReturn($this->connection); $this->ufRepository->method('getTable')->willReturn('uf'); } public function testGet(): void { $provider = new Service\Money\SII($this->client, $this->ufRepository); $date = new \DateTimeImmutable('2025-05-05'); $expected = 39107.9; $this->assertEquals($expected, $provider->get(Service\Money::UF, $date)); } public function testGetNoValid(): void { $provider = new Service\Money\SII($this->client, $this->ufRepository); $date = (new \DateTimeImmutable())->add(new \DateInterval("P1Y")); $this->expectException(EmptyResponse::class); $provider->get(Service\Money::UF, $date); } }