Files
oleibman 3697352e28 Fix Unintential Deprecated Calls in Tests - LOGICAL (#3178)
* Fix Unintential Deprecated Calls in Tests - LOGICAL

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

* Change Unit Tests to Run in Spreadsheet Context

They had been run as direct calls, which is not how most users would use them. Making this change exposed some minor coding errors - SWITCH needs to flatten its arguments, and IFERROR and IFNA were not handling a null testValue in the same manner as Excel.
2022-11-23 07:49:28 -08:00

31 lines
1.7 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests\Calculation\Functions\Logical;
use PhpOffice\PhpSpreadsheet\Calculation\Logical;
use PHPUnit\Framework\TestCase;
// Sanity tests for functions which have been moved out of Functions
// to their own classes. A deprecated version remains in Functions;
// this class contains cursory tests to ensure that those work properly.
// If Scrutinizer fails the PR because of these deprecations, I will
// remove this class from the PR.
class DeprecatedFunctionsTest extends TestCase
{
public function testDeprecated(): void
{
self::assertFalse(/** @scrutinizer ignore-deprecated */ Logical::false());
self::assertFalse(/** @scrutinizer ignore-deprecated */ Logical::logicalAnd(true, false));
self::assertTrue(/** @scrutinizer ignore-deprecated */ Logical::NOT(false));
self::assertTrue(/** @scrutinizer ignore-deprecated */ Logical::logicalOr(true, false));
self::assertTrue(/** @scrutinizer ignore-deprecated */ Logical::logicalXor(true, false));
self::assertTrue(/** @scrutinizer ignore-deprecated */ Logical::true());
self::assertFalse(/** @scrutinizer ignore-deprecated */ Logical::statementIf(false));
self::assertSame('error', /** @scrutinizer ignore-deprecated */ Logical::IFERROR('#VALUE!', 'error'));
self::assertSame('#VALUE!', /** @scrutinizer ignore-deprecated */ Logical::IFNA('#VALUE!', 'error'));
self::assertSame('two', /** @scrutinizer ignore-deprecated */ Logical::IFS(false, 'one', true, 'two', true, 'three'));
self::assertSame(31, /** @scrutinizer ignore-deprecated */ Logical::statementSwitch(30, 10, 11, 20, 21, 30, 31, 40, 41));
}
}