M
M
microf2020-05-11 06:48:33
PHP
microf, 2020-05-11 06:48:33

How to make a test and design a method?

Good afternoon.
There is an entity that stores balance sheets for several years:

$company = new Company(
                $id = ID::generate(),
                $name = new Name('Ромашка"'),                
                ....
                $accounting = [          
                    new BalanceSheet('2017,'356743','-56913','189632','122733'),
                    new BalanceSheet('2018','76743','-16953','1492','233')
                ]
        );

I would like to design the ability to change the balance stored in $accounting
I.e. make some method refreshBalance
I write a test
$company = (new CreateBuilder())
                ->withAccounting([
                                                     //year// 
                     new BalanceSheet('2018','356743','-56913','189632','122733'),
                    new BalanceSheet('2018','76743','-16953','1492','233')
                    ])
                ->build();
     $company->refreshBalance($newBalance = new BalanceSheet('2018', '556743', '-56913', '189632', '122733'));
        $this->assertEquals($newBalance, $company->getBalance('2018'));

And then I can't figure it out. If I make a method to get the balance for a certain year, then should I make the year the key?
getBalance($year) { return а что ретурн он должен?}

Need to make a yearkey
BalanceSheet('2018', ['556743', '-56913', '189632', '122733']))
?
And do it accordingly
refreshBalance(new BalanceSheet('2018', ['556743', '-56913', '189632', '122733'])))
, and the method should check for `2018`?
Sorry if I messed up

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question