Codeception / Codeception/AspectMock

Unable to instrument classes in the /vendor directory

Đang mở
#139 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
784
Fork
132
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

I was able to get AspectMock to instrument my own classes in my directory but I can not get it to work on classes in the composer `/vendor` directory....

Is this even possible?

I tried adding vendor to my `includePaths` but I get the issue in #112

My bootstrap looks basically like this:
```php
require_once __DIR__.'/../vendor/autoload.php'; // composer autoload

$kernel = \AspectMock\Kernel::getInstance();
$kernel->init([
'debug' => true,
'appDir' => __DIR__.'/..',
'cacheDir' => __DIR__.'/_data/aopcache',
'includePaths' => [
__DIR__.'/../repo'
],
'excludePaths' => [
__DIR__,
]
]);
```

Sample of my test code:
```php
$testDataStr = 'var=1&var=2';
$paypalIPN = test::double(new \PayPal\IPN\PPIPNMessage($testDataStr), [
'getRawData' => ['Returned test double'],
]);
$this->assertTrue($paypalIPN->class->hasMethod('getRawData'));
$testData = $paypalIPN->getRawData();
$paypalIPN->verifyInvoked('getRawData'); // fails
```
fails with:
```Expected PayPal\IPN\PPIPNMessage->getRawData to be invoked but it never occurred. Got:```

**Versions**
php 5.6.30
codeception/aspect-mock:2.0.1 @b7f5c50da89419824102400bb4c71988ec33044f
goaop/framework:2.1.2 @6e2a0fe13c1943db02a67588cfd27692bddaffa5
goaop/parser-reflection:1.4.0 @adfc38fee63014880932ebcc4810871b8e33edc9

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu với cấu hình bootstrap được hiển thị trong issue và tái hiện bài kiểm thử bằng PayPal\IPN\PPIPNMessage, tập trung vào includePaths, excludePaths và Composer autoloading. Truy tìm lý do test::double không chặn getRawData đối với lớp trong /vendor. Hoàn tất khi lời gọi được chặn và verifyInvoked('getRawData') chạy qua.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
php
Lĩnh vực
testing
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Cần làm rõ
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.