Codeception / Codeception/AspectMock

AspectMock не мокает объект

Aperta
#206 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
PHP
Stelle
784
Fork
132
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Не мокается обхект тест запускается хорошо но не работает

```php
bootstrap.php

init([
'debug' => true,
'appDir' => 'app',
'cacheDir' => __DIR__ . '/../runtime/myapp',
'includePaths' => [
__DIR__.'/..'
],
'excludePaths' => [__DIR__]
]);
$kernel->loadFile(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');

Yii::setAlias('@tests', dirname(__DIR__));
Yii::setAlias('@app', dirname(dirname(__DIR__)));

сам код

класс который мокаю

[
'title' => 'Имя',
'type' => 'string',
'identify' => true,
'maxLength' => 255,
],
'description' => [
'title' => 'Описание',
'type' => 'text',
],
];

public static $permanentlyDelete = true;

protected static $hiddable = false;

protected static $modelTitle = 'Методы API';

protected static $recordTitle = 'метод API';

protected static $accusativeRecordTitle = 'метод API';

protected static $readonly = true;

/**
* @inheritdoc
*/
public static function tableName()
{
return 'api_methods';
}

/**
* @inheritdoc
*/
public function rules()
{
return [];
}
}

$methods = \AspectMock\Test::double('app\modules\api\models\base\Methods', [
'tableName' => 34
]);

$n2 = Methods::tableName();
//$methods->verifyInvoked('tableName');

print_r($n2); печатает api_methods вместо 34
exit;

```
### Details

* Codeception version:
* PHP Version: 8.1
* Operating System: windiws

```yml
codeception.yml

namespace: Tests
support_namespace: Support
paths:
tests: tests
output: tests/_output
data: tests/Support/Data
support: tests/Support
envs: tests/_envs
settings:
bootstrap: ../_bootstrap.php
error_level: E_ALL & ~E_STRICT & ~E_DEPRECATED
memory_limit: 1024M
colors: true
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
Yii2:
configFile: 'config/test-local.php'
cleanup: false

# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

Unit.suite.yml

actor: UnitTester
modules:
enabled:
- Asserts
- Yii2:
part: [orm]
- Db:
dsn: 'mysql:host=db;dbname=lkp'
user: 'root'
password: 'lkp_dev_passwd'
step_decorators: ~

```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.