Files
oleibman d93a303371 Fix Unintential Deprecated Calls in Tests - ENGINEERING (#3176)
* Fix Unintential Deprecated Calls in Tests - ENGINEERING

I think it's best to install these before PR #3166. There are no changes to source code, only to test members which continue to inadvertently use calls to deprecated functions.

* Fix deprecation DocBlocks

Deprecated->deprecated, adjust see and comments

* Fix Deliberate Deprecated Tests

Add annotations.

* Run Unit Tests in Spreadsheet Context

This turned up only one error, in IMSUB. The only group that still needs this is Statistical. Not sure if I will get to that quickly.
2022-11-24 07:57:41 -08:00

63 lines
1.8 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Engineering;
use PhpOffice\PhpSpreadsheet\Calculation\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcExp;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PHPUnit\Framework\TestCase;
class BitOrTest extends TestCase
{
/**
* @dataProvider providerBITOR
*
* @param mixed $expectedResult
*/
public function testBITOR($expectedResult, string $formula): void
{
if ($expectedResult === 'exception') {
$this->expectException(CalcExp::class);
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A2', 8);
$sheet->getCell('A1')->setValue("=BITOR($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEquals($expectedResult, $result);
$spreadsheet->disconnectWorksheets();
}
public function providerBITOR(): array
{
return require 'tests/data/Calculation/Engineering/BITOR.php';
}
/**
* @dataProvider providerBitOrArray
*/
public function testBitOrArray(array $expectedResult, string $number1, string $number2): void
{
$calculation = Calculation::getInstance();
$formula = "=BITOR({$number1}, {$number2})";
$result = $calculation->_calculateFormulaValue($formula);
self::assertEquals($expectedResult, $result);
}
public function providerBitOrArray(): array
{
return [
'row/column vector' => [
[
[7, 11, 11],
[7, 12, 13],
[7, 13, 13],
],
'{7, 8, 9}',
'{3; 4; 5}',
],
];
}
}