Code Monkey home page Code Monkey logo

vscode-phpunit's Introduction

Hi there, I'm Renan Delmonico!

I'm a Software Engineer at PagSeguro, where I'm involved in the development of event-driven financial applications. I utilize my expertise in technologies such as PHP, Kafka, CQRS, and Hexagonal Architecture to contribute to the company's mission of providing secure and reliable cross-border payments. As part of my role, I also participate in on-call rotations to ensure the quality and reliability of our applications.

Experience

I've been working with web development since 2013, starting at a web development agency before moving on to a large retail company where I spent 4 years. Since then, I've been working with software development at a variety of companies, with a focus on building scalable and reliable applications.

Technologies

Throughout my career, I've worked with a wide range of technologies, including:

I have experience working with APIs, websites, event-driven applications, microservices, CQRS, hexagonal architecture, and several other technologies not mentioned here.

Talks

I've had the opportunity to speak at some events, including:

  • Vida de Programador Weekend
  • Jornada Acadêmica - Faculdade Alfa Umuarama / Faculdade Integrada Campo Mourão
  • 2º Meetup DevParaná Umuarama

You can see the talks and slides on my GitHub page.

Education

I hold a bachelor's degree in Information Systems from Unipar, and I've also completed a Web Development specialist course at Alfa Umuarama.

Connect with me

vscode-phpunit's People

Contributors

amir9480 avatar aphix-mark avatar dependabot[bot] avatar dominicvonk avatar jellisii avatar ngyuki avatar recca0120 avatar renandelmonico avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-phpunit's Issues

phpunit.ssh setting not working

Hi !

I used PHPUnit extension to connect to remote machine successfuly. I run tests using "Ctrl+Shift+P -> PHPUnit Test -> myTestCase" as instance. See output below.

PHPUnit 8.5.26
Runtime: PHP 7.2.24-0ubuntu0.18.04.11 with Xdebug 2.6.0
Configuration: /home/sb-0/phpunit.xml
...... 6 / 6 (100%)
Time: 31.95 seconds, Memory: 16.00 MB
OK (6 tests, 7 assertions)

But when I run test using Test Explorer, or Run in top label of test function headers, the output command executed automatically by extension ignores ssh configuration and runs directly "phpunit.php": "/usr/bin/php", command. See output below.

[INFO] {
title: 'PHPUnit LSP',
command: '/usr/bin/php',
arguments: [
'/home/sb-0/www/iats/code/resources/composer/phpunit/phpunit/phpunit',
'-v',
'-c',
'/home/sb-0/phpunit.xml',
'--filter',
'/^.::testBadgeName.$/',
'/home/sb-0/www/iats/code/module/badge/test/BadgeUnitTest.phpunit.php'
]
}

How can we use current phpunit configuration to run tests using PHPUnit Test Explorer extension?
Am I doing something wrong?

Thnaks !!
Great work!!

Not working with Docker and WSL2 - Windows 10 - wrong path escaped

I am trying to run this inside Docker in Windows 10 with WSL2, but it is not working at all. The screenshot shows the definitions I am using and that the path escaped by the spawn command shows it wrong.

image

Executing the correct command would work, as show in the next screenshot:

image

"FAILURES!" = Pass

Hey
Thanks for continuing the development of the original extension!

Just wanted to let you know that the issue reported in recca0120#104 is still a problem in this version here.


I run PHPUnit in Docker (I develop on Windows), with these settings:

Workspace settings:

		"phpunit.php": "",
		"phpunit.phpunit": "C:\\node\\npm.cmd",
		"phpunit.args": ["run", "build-runtests", "--"],
		"phpunit.relativeFilePath": true,
		"phpunit.remoteCwd": "/opt/app/",
		"phpunit.files": "myapp/tests/*Test.php",

packages.json:

"build-runtests": "gulp build-debug && docker-compose run --rm --entrypoint 'php' myapp /opt/app/myapp/tests/run_phpunit.php",

My run_phpunit.php basically runs the test(s), prints the output, and returns a proper return code (would be "1" if tests fail).
I confirm that it's definitely returning the right error code.

The problem I have with this is that if there are tests that fail, I'm still seeing a green success icon:

image

After several experiments, I realized that as long as the output contains "FAILURES!", the test will be successful.

run_phpunit.php:

    echo "FAILURES!";
    exit(1);

image

run_phpunit.php:

    echo "SUCCESS!";
    exit(1);

image

I'm using testdox="true" in my phpunit.xml, btw.

Somehow, it appears to me that this extension is looking at the output, rather than relying on the exit code,
and there's a bug in the way it looks at the output.

To fix this, I'm changing my run_phpunit.php so that if there are failures, it will replace "FAILURES!" with something else...

run_phpunit.php:

    $rc = null;
    $cmd_output_ar = array();
    exec($cmd, $cmd_output_ar, $rc);
    $output = implode("\n", $cmd_output_ar);
    echo str_replace('FAILURES!', '', $output);

image

plugin inject wrong config file

I have a DDEV project I run in Remote WSL session.

If I configure this plugin to run with the following settings

    "phpunit.relativeFilePath": true,
    "phpunit.phpunit": "/var/www/html/vendor/bin/phpunit",
    "phpunit.docker": true,
    "phpunit.dockerImage": "docker exec -it 833f9",

I get the following error:

spawn docker exec -it 833f9 bash -c "var/www/html/vendor/bin/phpunit -c /home/user13/code/phpunit.xml" ENOENT

The following is successful

  • docker exec -it 833f9 "/var/www/html/vendor/bin/phpunit"

I do not understand why -c /home/user13/code/phpunit.xml is being injected.
This config file is my WSL path. If the command is running in docker, then it should be the dockered path?

I check the actual path:

docker exec -it 833f9 "bash"

$ find ~+ -type f -name phpunit.xml
/var/www/html/phpunit.xml

I can run the following in my terminal:

  • docker exec -it 833f9 bash -c "/var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml"

So I think the correct spawn command should be:

  • spawn docker exec -it 833f9 bash -c "/var/www/html/vendor/bin/phpunit -c /var/www/html/phpunit.xml"
  • spawn docker exec -it 833f9 bash -c "/var/www/html/vendor/bin/phpunit -c /home/user13/code/phpunit.xml"

VSCode 1.66.2
renandelmonico.vscode-php-test-explorer 1.0.1

PHP server is crashing

I´m using the phpunit extension and i'm having a few issues.

I can run my tests 2 or 3 times before I get the following error in the picture.

image

After this happens I only can run my tests after restarting vscode.

Below is the following error that is printed in the output.

image

settings.json

{
    "phpunit.phpunit": "/var/www/vendor/bin/phpunit",
    "testExplorer.useNativeTesting": true,
    "phpunit.files": "tests/**/*Test.php",
    "phpunit.remoteCwd": "/var/www",
    "phpunit.relativeFilePath": true,
    "phpunit.php": "/usr/bin/docker compose exec -T accounts2 ",
    "phpunit.shell": "bash",
    "phpunit.args": ["--configuration ./phpunit.xml"]
}

TypeError: Cannot read properties of undefined (reading 'loc')

Every time I save a change on a file that is not inside the main folder of the workspace (but it's a folder in the folders settings of the workspace), I get this crash and I must restart VSCode to be able to run tests again:

TypeError: Cannot read properties of undefined (reading 'loc')
	at n.swapLocations (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:154736)
	at n.resolvePrecedence (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:155463)
	at a (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:157455)
	at r.read_expr (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:217563)
	at r.read_expr_item (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:219090)
	at r.read_expr (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:216069)
	at r.read_argument_list (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:228199)
	at r.read_function_argument_list (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:227870)
	at r.recursive_variable_chain_scan (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:250227)
	at r.read_variable (c:\Users\myuser\.vscode\extensions\renandelmonico.vscode-php-test-explorer-1.0.2\server\out\server.js:2:248412)
[Info  - 16:24:08] Connection to server got closed. Server will restart.

If you need to know my configs, please let me know.
Thank you!

Not working with Docker and differents paths

In my local project the paths is src/ but in docker it is mounted as /var/www/html/.

    volumes:
      - ./src/:/var/www/html/:rw

When the test is launched it runs as "src/tests/Unit/ExampleTest.php" and shows an error, but it should be "tests/Unit/ExampleTest.php".

$ docker-compose exec container bash -c "vendor/bin/phpunit --configuration ./phpunit.xml --filter /^.*::testThatTrueIsTrue.*$/ src/tests/Unit/ExampleTest.php"

But the correct:

$ docker-compose exec container bash -c "vendor/bin/phpunit --configuration ./phpunit.xml --filter /^.*::testThatTrueIsTrue.*$/ tests/Unit/ExampleTest.php"

Would there be a possibility to add an option with mapped paths? ex:

"phpunit.pathMappings": {
    "${workspaceRoot}/src/":"/var/www/html/"
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.