RandTest.php 725 B

123456789101112131415161718192021222324
  1. <?php
  2. namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\MathTrig;
  3. class RandTest extends AllSetupTeardown
  4. {
  5. public function testRand(): void
  6. {
  7. $sheet = $this->getSheet();
  8. $sheet->getCell('B1')->setValue('=RAND()');
  9. $result = $sheet->getCell('B1')->getCalculatedValue();
  10. self::assertGreaterThanOrEqual(0, $result);
  11. self::assertLessThanOrEqual(1, $result);
  12. }
  13. public function testRandException(): void
  14. {
  15. $this->mightHaveException('exception');
  16. $sheet = $this->getSheet();
  17. $sheet->getCell('B1')->setValue('=RAND(A1)');
  18. $result = $sheet->getCell('B1')->getCalculatedValue();
  19. self::assertEquals(0, $result);
  20. }
  21. }