SlowPasswordHasherのテスト(Travis CIためす準備)

はじめに

Travis CIというものを試してみたいのです。
GitHubにコミットされたソースコードを取得してビルド、テストしてくれるものらしいです。
たぶんテストされるのとテストするのがないと試してもよくわからないので
まず、先日のSlowPasswordHasher.phpユニットテストを作ります。

github

テストされるアプリケーション(d365)は下記にあります。

テスト作成

\app\Test\Case\Controller\Component\AuthにSlowPasswordHasherTest.php作成して
コミットします。

<?php

App::uses('SlowPasswordHasher', 'Controller/Component/Auth');

/**
 * Class SlowPasswordHasherTest
 */
class SlowPasswordHasherTest extends CakeTestCase {

    public function setUp() {
        parent::setUp();
        $this->passwordHasher = new SlowPasswordHasher();
    }

    public function testMatchPassword() {
        $rawPassword = 'p@ssword21';
        $hashed = $this->passwordHasher->hash($rawPassword);
        $this->assertTrue($this->passwordHasher->check($rawPassword, $hashed));
    }

    public function testUnmatchPassword() {
        $rawPassword = 'p@ssword21';
        $missPassword = 'p@ssword22';
        $hashed = $this->passwordHasher->hash($missPassword);
        $this->assertFalse($this->passwordHasher->check($rawPassword, $hashed));
    }

}

テストはグリーンです。
f:id:ikechampion:20140204175343p:plain

Travis CI

GitHubにコミットしたらTravis CIと連携してみます。
https://travis-ci.org/」の「Sign in with Github」リンクを押すと
勝手にビルドされましたがFailedです。

Could not find .travis.yml, using standard configuration.

たぶん、.travis.ymlにどんなテストやら解析するのかいろいろ書いてあげるんだと思われますが
時間切れなので明日やってみます。

継続的デリバリー 信頼できるソフトウェアリリースのためのビルド・テスト・デプロイメントの自動化

継続的デリバリー 信頼できるソフトウェアリリースのためのビルド・テスト・デプロイメントの自動化