facebook twitter hatena line google mixi email

Php/zend framework/test方法

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

zendの環境変数を通す

$ vi ~/.bash_profile
alias=zf='/usr/lib/php/ZendFramework-1.12.0-minimal/bin/zf.sh'
$ source ~/.bash_profile

プロジェクトスケルトン作成

zf create project samplezend

phpunitをインストール(mac

sudo pear channel-discover pear.phpunit.de
sudo pear channel-discover pear.symfony.com
sudo pear install phpunit/PHPUnit
phpunit --version

phpunit実行

cd samplezend/tests
phpunit
phpunit application/controllers/IndexControllerTest

phpunit.xml

<phpunit bootstrap="./application/bootstrap.php" colors="true">
  <testsuites>
    <testsuite name="Application Test Suite">
       <directory>./application</directory>
    </testsuite>
    <testsuite name="Library Test Suite">
       <directory>./library</directory>
       <exclude>
         <directory suffix=".php">/path/to/files</directory>
         <file>/path/to/file</file>
       </exclude>
    </testsuite>
  </testsuites>
  <filter>
      <whitelist>
          <directory>./</directory>
          <exclude>
              <directory>../library/ZendFramework-1.12.14-minimal</directory>
              <directory>../vendor</directory>
          </exclude>
      </whitelist>
  </filter>
   <logging>
       <log type="coverage-text" target="php://stdout" showUncoveredFiles="true"/>
   </logging>
</phpunit>