mercredi 2 décembre 2015

Return variables from mock(php)

I want test some variable inside function, but this function don't return it.

I have function like this:

<?php

class Test 
{

   private $repo;       

   public function __construct($repo)
   {
        $this->repo = $repo;
   }

   public function exemple()
   {
        $name = 'Example name';
        $this->repo->add($name);
   }

}

And test like this:

<?php

use Mockery as M;

class someTest extends TestCase
{
   public testConstract()
   {
       $repo = M::mock(SomeClass::class);
       $repo->shouldReceive('add');
       $test = new Test($repo);
       $test->exemple();
   }
}

How I can test variable $name?

Aucun commentaire:

Enregistrer un commentaire