LoginSignup
11

More than 5 years have passed since last update.

composer.jsonでPHPUnitをインストール

Last updated at Posted at 2014-11-19

インストール手順

composer.jsonのrequire-devに以下を追加

composer.json
{
    "require-dev": {
        "phpunit/phpunit": "4.3.*"
    }
}

インストール!

$ composer install --dev

インストールされているか確認

$ vendor/bin/phpunit --version
PHPUnit 4.3.5 by Sebastian Bergmann.

テストを書いてみる

PracticeTest.php
<?php

class PracticeTest extends PHPUnit_Framework_TestCase {
    public function testHelloWorld()
    {
        $message = 'Hello, World!';

        $this->assertTrue($message === 'Hello, World!');
    }
}

テスト開始

$ vendor/bin/phpunit tests
PHPUnit 4.3.5 by Sebastian Bergmann.

.

Time: 107 ms, Memory: 2.75Mb

OK (1 test, 1 assertion)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11