PhpSpreadsheet/tests/PhpSpreadsheetTests/CalculationTest.php
Adrien Crivelli 56245d558e
Use ::class notation as much as possible
```
               *             ,
                           _/^\_
                          <     >
         *                 /.-.\         *
                  *        `/&\`                   *
                          ,@.*;@,
                         /_o.I %_\    *
            *           (`'--:o(_@;
                       /`;--.,__ `')             *
                      ;@`o % O,*`'`&\
                *    (`'--)_@ ;o %'()\      *
                     /`;--._`''--._O'@;
                    /&*,()~o`;-.,_ `""`)
         *          /`,@ ;+& () o*`;-';\
                   (`""--.,_0 +% @' &()\
                   /-.,_    ``''--....-'`)  *
              *    /@%;o`:;'--,.__   __.'\
                  ;*,&(); @ % &^;~`"`o;@();         *
                  /(); o^~; & ().o@*&`;&%O\
            jgs   `"="==""==,,,.,="=="==="`
               __.----.(\-''#####---...___...-----._
             '`         \)_`"""""`
                     .--' ')
                   o(  )_-\
                     `"""` `
```
2016-12-26 13:21:12 +09:00

64 lines
2.1 KiB
PHP

<?php
namespace PhpOffice\PhpSpreadsheetTests;
use PhpOffice\PhpSpreadsheet\Calculation;
use PhpOffice\PhpSpreadsheet\Calculation\Functions;
class CalculationTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
}
/**
* @dataProvider providerBinaryComparisonOperation
*
* @param mixed $formula
* @param mixed $expectedResultExcel
* @param mixed $expectedResultOpenOffice
*/
public function testBinaryComparisonOperation($formula, $expectedResultExcel, $expectedResultOpenOffice)
{
Functions::setCompatibilityMode(Functions::COMPATIBILITY_EXCEL);
$resultExcel = Calculation::getInstance()->_calculateFormulaValue($formula);
$this->assertEquals($expectedResultExcel, $resultExcel, 'should be Excel compatible');
Functions::setCompatibilityMode(Functions::COMPATIBILITY_OPENOFFICE);
$resultOpenOffice = Calculation::getInstance()->_calculateFormulaValue($formula);
$this->assertEquals($expectedResultOpenOffice, $resultOpenOffice, 'should be OpenOffice compatible');
}
public function providerBinaryComparisonOperation()
{
return require 'data/CalculationBinaryComparisonOperation.php';
}
/**
* @dataProvider providerGetFunctions
*
* @param mixed $category
* @param mixed $functionCall
* @param mixed $argumentCount
*/
public function testGetFunctions($category, $functionCall, $argumentCount)
{
$this->assertInternalType('callable', $functionCall);
}
public function providerGetFunctions()
{
return Calculation::getInstance()->getFunctions();
}
public function testIsImplemented()
{
$calculation = Calculation::getInstance();
$this->assertFalse($calculation->isImplemented('non-existing-function'));
$this->assertFalse($calculation->isImplemented('AREAS'));
$this->assertTrue($calculation->isImplemented('coUNt'));
$this->assertTrue($calculation->isImplemented('abs'));
}
}