Symfony3-Codeception-AspectMock config
Shaamin opened this issue · 1 comments
Shaamin commented
Hi! I use Symfomy3 and Codeception. A few days ago i was wanted to use the AspectMock. Before there, i was use Yii2-Codeception-AspectMock and there are worked fine, but Symfomy3-Codeception-AspectMock does not worked. Please, help me with configurational AspectMock for Symfomy3.
Near is my config and test files.
My config (_bootstrap.php):
require_once __DIR__.'/../vendor/autoload.php';
$kernel = \AspectMock\Kernel::getInstance();
$kernel->init([
'debug' => true,
'includePaths' => [
__DIR__.'/../src',
]
]);
$kernel->loadFile(__DIR__.'/../app/autoload.php');
$kernel->loadFile(__DIR__.'/../app/Kernel.php');
api.suite.yml:
actor: ApiTester
modules:
enabled:
- REST:
url: http://127.0.0.1:8081/app_test.php
depends: PhpBrowser
part: Json
- \Helper\Api
- \Helper\FixtureHelper
error_level: "E_ALL & ~E_STRICT & ~E_DEPRECATED & ~E_USER_DEPRECATED"
app_test.php:
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Debug\Debug;
/**
* @var Composer\Autoload\ClassLoader $loader
*/
$loader = require_once __DIR__.'/../app/autoload.php';
Debug::enable();
require_once __DIR__ . '/../app/PlacetGroupManagerKernel.php';
$kernel = new PlacetGroupManagerKernel('test', false);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
ExampleCest.php
class ExampleCest
{
public function test(\ApiTester $I)
{
$I->wantTo('test AspectMock);
test::double(User::class, ['getId' => '123']);
$I->sendGET("/rest/v1/user");
$I->seeResponseIsJson();
$I->seeResponseContainsJson([
'id' => '123',
]);
}
Expected Result: Class User mocked and test was pased
Shaamin commented
Issue resolved
I've just change in api.suite.yml
depends: PhpBrowser
to
depends: Symfony