Java vs PHP for Testing
- Java vs JavaScript for testing
- PLEASE READ IF YOU THINK YOUR ARE DOING TESTING WITH BDD - ODDS ARE YOU ARE NOT
UserTest.php
<?php
use PHPUnit\Framework\TestCase;
class UserTest extends TestCase
{
public function testThatWeCanGetTheFirstName(){
$user = new \App\Models\User;
$user->setFirstName('Billy');
$this->assertEquals($user->getFirstName(),'Billy');
}
public function testTrueAssertsToTrue()
{
$this->assertTrue(true);
}
}
Run
w:\w\git\phpunitbasics (develop-init-setup -> origin)
λ vendor\bin\phpunit
PHPUnit 7.4.4 by Sebastian Bergmann and contributors.
Runtime: PHP 7.2.9
Configuration: W:\w\git\phpunitbasics\phpunit.xml
.E. 3 / 3 (100%)
Time: 48 ms, Memory: 4.00MB
There was 1 error:
tests/SampleTest.php
<?php
use PHPUnit\Framework\TestCase;
class SampleTest extends TestCase
{
}
Execution
w:\w\git\phpunitbasics (develop-init-setup -> origin)
λ vendor\bin\phpunit
PHPUnit 7.4.4 by Sebastian Bergmann and contributors.
Runtime: PHP 7.2.9
Configuration: W:\w\git\phpunitbasics\phpunit.xml
W 1 / 1 (100%)
Time: 45 ms, Memory: 4.00MB
There was 1 warning:
1) Warning
No tests found in class "SampleTest".
WARNINGS!
Tests: 1, Assertions: 0, Warnings: 1.
Add a function
<?php
use PHPUnit\Framework\TestCase;
PHP: Locate installation Directory
php --ini
<?php phpinfo(); ?>
<?php
// prints e.g. 'Current PHP version: 4.1.1'
echo 'Current PHP version: ' . phpversion();
?>
If you are using the PHP CLI, then try using theese shell commands (i'm assuming that you are using linux here)
which php - will locate the php executable (this should be the default php used by you)
whereis php - The first path displayed will be the location of the php executable
echo $PATH - will print a list of paths separated by ":" where the system looks for commands
composer.json
composer.phar
Copyright 2018· All rights reserved