Files
PhpSpreadsheet/tests/PhpSpreadsheetTests/Calculation/Functions/Engineering/BitAndTest.php
T
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 BitAndTest extends TestCase
{
/**
* @dataProvider providerBITAND
*
* @param mixed $expectedResult
*/
public function testBITAND($expectedResult, string $formula): void
{
if ($expectedResult === 'exception') {
$this->expectException(CalcExp::class);
}
$spreadsheet = new Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
$sheet->setCellValue('A2', 24);
$sheet->getCell('A1')->setValue("=BITAND($formula)");
$result = $sheet->getCell('A1')->getCalculatedValue();
self::assertEquals($expectedResult, $result);
$spreadsheet->disconnectWorksheets();
}
public function providerBITAND(): array
{
return require 'tests/data/Calculation/Engineering/BITAND.php';
}
/**
* @dataProvider providerBitAndArray
*/
public function testBitAndArray(array $expectedResult, string $number1, string $number2): void
{
$calculation = Calculation::getInstance();
$formula = "=BITAND({$number1}, {$number2})";
$result = $calculation->_calculateFormulaValue($formula);
self::assertEquals($expectedResult, $result);
}
public function providerBitAndArray(): array
{
return [
'row/column vector' => [
[
[3, 0, 1],
[4, 0, 0],
[5, 0, 1],
],
'{7, 8, 9}',
'{3; 4; 5}',
],
];
}
}