PHP Classes

File: test/TanTest.php

Recommend this page to a friend!
  Classes of stefan   PHP Calculator   test/TanTest.php   Download  
File: test/TanTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Calculator
Calculate the result of multiple math operations
Author: By
Last change: resolve error ( and sin( in same term
Date: 2 years ago
Size: 1,728 bytes
 

Contents

Class file image Download
<?php declare(strict_types=1);
use
PHPUnit\Framework\TestCase;
    use
Taschenrechner\Classes\Calculator;
    use
Taschenrechner\Classes\Operationen\Tan;
    use
Taschenrechner\Classes\Concatinator;
    require_once
"init.php";

require_once(
dirname(__FILE__)."/../vendor/autoload.php");

final class
TanTest extends TestCase
{
    private
$operation;
    private
$concatinator;
    private
$calculator;
    protected function
setUp(): void
   
{
       
$this->calculator = $this->createMock(Calculator::class);
       
$this->concatinator = $this->createMock(Concatinator::class);
    }
   

   
    public function
addTermProvider() {
        return array(
           
"Term tan(2) equals 0.034899496702501" => array(array("tan(",2,")"),"tan(2)" ,"0.034920769491748"),
           
"Term tan(4) equals 0.069756473744125" => array(array("tan(",4,")"),"tan(4)" ,"0.06992681194351"),
           
"Term 2*tan(4) equals 2*0.069756473744125" => array(array("2","*","tan(",4,")"),"2*tan(4)" ,"2*0.06992681194351"),
           
"Term tan(4)*2 equals 0.069756473744125*2" => array(array("tan(",4,")","*","2"),"tan(4)*2" ,"0.06992681194351*2"),
        );
    }

   
/**
     * @dataProvider addTermProvider
     */
   
public function testTerm($concatinatedValues, $term, $expected)
    {
       
$this->operation = new Tan($this->calculator, $this->concatinator);
       
$this->concatinator->method('concatinateArray')->willReturn($concatinatedValues);
       
       
$this->assertSame($expected, $this->operation->findAndCalculateTerm($term, (new Init())->operations()));

    }

    protected function
tearDown(): void
   
{
       
$this->calculator = NULL;
       
$this->concatinator = NULL;

    }
  
}