PHP Classes

File: test/SinTest.php

Recommend this page to a friend!
  Classes of stefan   PHP Calculator   test/SinTest.php   Download  
File: test/SinTest.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,735 bytes
 

Contents

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

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

final class
SinTest 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 sin(2) equals 0.034899496702501" => array(array("sin(",2,")"),"sin(2)" ,"0.034899496702501"),
           
"Term sin(4) equals 0.069756473744125" => array(array("sin(",4,")"),"sin(4)" ,"0.069756473744125"),
           
"Term 2*sin(4) equals 2*0.069756473744125" => array(array("2","*","sin(",4,")"),"2*sin(4)" ,"2*0.069756473744125"),
           
"Term sin(4)*2 equals 0.069756473744125*2" => array(array("sin(",4,")","*","2"),"sin(4)*2" ,"0.069756473744125*2"),
        );
    }

   
/**
     * @dataProvider addTermProvider
     */
   
public function testTerm($concatinatedValues, $term, $expected)
    {
       
$this->operation = new Sinus($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;

    }
  
}