SlideShare a Scribd company logo
['begin',
	 	 ['define',
	 	 	 	 'fib',
	 	 	 	 ['lambda',
	 	 	 	 	 	 ['x'],
	 	 	 	 	 	 ['if',
	 	 	 	 	 	 	 	 ['<',	 ':x',	 2],
	 	 	 	 	 	 	 	 ':x',
	 	 	 	 	 	 	 	 ['+',
	 	 	 	 	 	 	 	 	 	 ['fib',	 ['-',	 ':x',	 2]],
	 	 	 	 	 	 	 	 	 	 ['fib',	 ['-',	 ':x',	 1]]]]]],
	 	 ['print',	 'fib(10)	 =	 '],
	 	 ['println',	 ['fib',	 10]]]
	 	 =>	 fib(10)	 =	 55
class CalculatorTest
  extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->calc = new Calculator;
    }

    public function test_add_           ()
    {
        $result = $this->calc->add(1, 2);
        $this->assertSame(3, $result);
    }
}
class CalculatorTest
  extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->calc = new Calculator;
    }

    public function test_add_           ()
    {
        $result = $this->calc->add(1, 2);
        $this->assertSame(3, $result);
    }
}
class CalculatorTest
  extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->calc = new Calculator;
    }

    public function test_add_           ()
    {
        $result = $this->calc->add(1, 2);
        $this->assertSame(3, $result);
    }
}
class CalculatorTest
  extends PHPUnit_Framework_TestCase
{
    public function setUp()
    {
        $this->calc = new Calculator;
    }

    public function test_add_           ()
    {
        $result = $this->calc->add(1, 2);
        $this->assertSame(3, $result);
    }
}
public function test_isValid_               true()
{
    $user = new User;
    $user->setName('Yuya');
    $user->setUrl('http://yuyat.jp/');
    $user->setAge(24);
    $this->assertTrue($user->isValid());
}

public function test_isValid_               false()
{
    $user = new User;
    $user->setName('Yuya');
    $user->setUrl('http://yuyat.jp/');
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_               true()
{
    $user = new User;
    $user->setName('Yuya');
    $user->setUrl('http://yuyat.jp/');
    $user->setAge(24);
    $this->assertTrue($user->isValid());
}

public function test_isValid_               false()
{
    $user = new User;
    $user->setName('Yuya');
    $user->setUrl('http://yuyat.jp/');
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_               true()
{
    $user = $this->createValidUser();
    $this->assertTrue($user->isValid());
}

public function test_isValid_               false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_               true()
{
    $user = $this->createValidUser();
    $this->assertTrue($user->isValid());
}

public function test_isValid_               false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_               true()
{
    $user = $this->createValidUser();
    $this->assertTrue($user->isValid());
}

public function test_isValid_               false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_               false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());

    $user = $this->createValidUser();
    $user->setName(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_               false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());

    $user = $this->createValidUser();
    $user->setName(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_               false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());

    $user = $this->createValidUser();
    $user->setName(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_           Null   false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());
}

public function test_isValid_           Null   false()
{
    $user = $this->createValidUser();
    $user->setName(NULL);
    $this->assertFalse($user->isValid());
}
public function test_isValid_           Null   false()
{
    $user = $this->createValidUser();
    $user->setAge(NULL);
    $this->assertFalse($user->isValid());
}

public function test_isValid_           Null   false()
{
    $user = $this->createValidUser();
    $user->setName(NULL);
    $this->assertFalse($user->isValid());
}
class Request
{
    public function isSsl()
    {
        return $_SERVER['HTTPS'] === 'on';
    }
}
class Request
{
    public function isSsl()
    {
        return $_SERVER['HTTPS'] === 'on';
    }
}
public function test_isSsl_HTTPS      true()
{
    $_SERVER['HTTPS'] = 'on';
    $this->assertTrue($this->request->isSsl());
}

public function test_isSsl_HTTPS        false()
{
    unset($_SERVER['HTTPS']);
    $this->assertFalse($this->request->isSsl());
}
public function test_isSsl_HTTPS      true()
{
    $_SERVER['HTTPS'] = 'on';
    $this->assertTrue($this->request->isSsl());
}

public function test_isSsl_HTTPS        false()
{
    unset($_SERVER['HTTPS']);
    $this->assertFalse($this->request->isSsl());
}
public function test_isSsl_HTTPS      true()
{
    $_SERVER['HTTPS'] = 'on';
    $this->assertTrue($this->request->isSsl());
}

public function test_isSsl_HTTPS        false()
{
    unset($_SERVER['HTTPS']);
    $this->assertFalse($this->request->isSsl());
}
public function test_isSsl_HTTPS      true()
{
    $_SERVER['HTTPS'] = 'on';
    $this->assertTrue($this->request->isSsl());
}

public function test_isSsl_HTTPS        false()
{
    unset($_SERVER['HTTPS']);
    $this->assertFalse($this->request->isSsl());
}
class Request
{
     public function __construct($server)
     {
         $this->_server = $server;
     }

     public function isSsl()
     {
         return $this->_server === 'on';
     }
}
class Request
{
     public function __construct($server)
     {
         $this->_server = $server;
     }

     public function isSsl()
     {
         return $this->_server === 'on';
     }
}
public function test_isSsl_HTTPS      true()
{
    $request = new Request(array('HTTPS' => 'on'));
    $this->assertTrue($request->isSsl());
}

public function test_isSsl_HTTPS        false()
{
    $request = new Request(array());
    $this->assertFalse($request->isSsl());
}
public function test_isSsl_HTTPS      true()
{
    $request = new Request(array('HTTPS' => 'on'));
    $this->assertTrue($request->isSsl());
}

public function test_isSsl_HTTPS        false()
{
    $request = new Request(array());
    $this->assertFalse($request->isSsl());
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }

    public static function findByName($name) { /*~*/ }
    public function save() { /*~*/ }
}
$user = User::findByName('Bob');

$user->setName('Alice');

$user->save();
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }
}

class UserMapper
{
    public function findByName($name) { /*~*/ }
    public function save(User $user) { /*~*/ }
}
$mapper = new UserMapper;

$user = $mapper->findByName('Bob');

$user->setName('Alice');

$mapper->save($user);
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }

    public static function findByName($name) { /*~*/ }
    public function save() { /*~*/ }
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }

    public static function findByName($name) { /*~*/ }
    public function save() { /*~*/ }
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }

    public static function findByName($name) { /*~*/ }
    public function save() { /*~*/ }
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }

    public static function findByName($name) { /*~*/ }
    public function save() { /*~*/ }
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }
}

class UserMapper
{
    public function findByName($name) { /*~*/ }
    public function save(User $user) { /*~*/ }
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }
}

class UserMapper
{
    public function findByName($name) { /*~*/ }
    public function save(User $user) { /*~*/ }
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }
}

class UserMapper
{
    public function findByName($name) { /*~*/ }
    public function save(User $user) { /*~*/ }
}
class User
{
    protected $_name;
    protected $_birthday;

    public function setName($name) { /*~*/ }
    public function getName() { /*~*/ }
    public function getAge() { /*~*/ }
}

class UserMapper
{
    public function findByName($name) { /*~*/ }
    public function save(User $user) { /*~*/ }
}
class Config
{
    protected static $_instance;

    private function __construct() {}

    public static function getInstance()
    {
        if (empty(self::$_instance)) {
            self::$_instance = new self;
        }
        return self::$_instance;
    }
}
public function __clone()
{
    throw new BadMethodCallException(
        'Clone is not allowed.'
    );
}
public function test_get_
 ()
{
    $config = Config::getInstance();
    $config->set('message', 'Hello');
    $this->assertSame(
        'Hello',
        $config->get('message')
    );
}
public function test_get_
   Null()
{
    $config = Config::getInstance();
    $this->assertNull(
        $config->get('message')
    );
}
public function test_get_
   Null()
{
    $config = Config::getInstance();
    $this->assertNull(
        $config->get('message')
    );
}
public function test_get_
   Null()
{
    $config = Config::getInstance();
    $config->init();
    $this->assertNull(
        $config->get('message')
    );
}
public function test_get_
   Null()
{
    $config = Config::getInstance();
    $config->init();
    $this->assertNull(
        $config->get('message')
    );
}
public function test_get_
   Null()
{
    $config = Config::getInstance();
    $config->init();
    $this->assertNull(
        $config->get('message')
    );
}
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために
PHPUnit でよりよくテストを書くために

More Related Content

What's hot

The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
Hugo Hamon
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
Hugo Hamon
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
Konstantin Kudryashov
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
Guilherme Blanco
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
Hugo Hamon
 
Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design Patterns
Hugo Hamon
 
Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"
Fwdays
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
Nikita Popov
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the newRemy Sharp
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
Lars Jankowfsky
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
XSolve
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
garux
 
R57shell
R57shellR57shell
R57shell
ady36
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
Mark Baker
 
Functional programming with php7
Functional programming with php7Functional programming with php7
Functional programming with php7
Sérgio Rafael Siqueira
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHP
Marcello Duarte
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il cliente
Leonardo Proietti
 
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Fabien Potencier
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
Vic Metcalfe
 

What's hot (20)

The History of PHPersistence
The History of PHPersistenceThe History of PHPersistence
The History of PHPersistence
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & REST
 
Agile database access with CakePHP 3
Agile database access with CakePHP 3Agile database access with CakePHP 3
Agile database access with CakePHP 3
 
Decoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DICDecoupling with Design Patterns and Symfony2 DIC
Decoupling with Design Patterns and Symfony2 DIC
 
PHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object CalisthenicsPHP for Adults: Clean Code and Object Calisthenics
PHP for Adults: Clean Code and Object Calisthenics
 
Design Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et PimpleDesign Patterns avec PHP 5.3, Symfony et Pimple
Design Patterns avec PHP 5.3, Symfony et Pimple
 
Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design Patterns
 
Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"Pim Elshoff "Final Class Aggregate"
Pim Elshoff "Final Class Aggregate"
 
PHP Language Trivia
PHP Language TriviaPHP Language Trivia
PHP Language Trivia
 
jQuery: out with the old, in with the new
jQuery: out with the old, in with the newjQuery: out with the old, in with the new
jQuery: out with the old, in with the new
 
Unittests für Dummies
Unittests für DummiesUnittests für Dummies
Unittests für Dummies
 
PHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolvePHPCon 2016: PHP7 by Witek Adamus / XSolve
PHPCon 2016: PHP7 by Witek Adamus / XSolve
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6
 
R57shell
R57shellR57shell
R57shell
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP Generators
 
Functional programming with php7
Functional programming with php7Functional programming with php7
Functional programming with php7
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHP
 
Symfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il clienteSymfony2, creare bundle e valore per il cliente
Symfony2, creare bundle e valore per il cliente
 
Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2Unit and Functional Testing with Symfony2
Unit and Functional Testing with Symfony2
 
Zero to SOLID
Zero to SOLIDZero to SOLID
Zero to SOLID
 

Viewers also liked

とある事業の脱レガシー
とある事業の脱レガシーとある事業の脱レガシー
とある事業の脱レガシーHisateru Tanaka
 
5分でわかる? 関数型 PHP の潮流
5分でわかる? 関数型 PHP の潮流5分でわかる? 関数型 PHP の潮流
5分でわかる? 関数型 PHP の潮流
Yuya Takeyama
 
Ioc & in direction
Ioc & in directionIoc & in direction
Ioc & in direction
育汶 郭
 
Good Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX PhilosophyGood Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX Philosophy
Yuya Takeyama
 
UnitTestのためのクラス設計
UnitTestのためのクラス設計UnitTestのためのクラス設計
UnitTestのためのクラス設計Takeshi Ishida
 
2007 5 30 肖镜辉 统计语言模型简介
2007 5 30 肖镜辉 统计语言模型简介2007 5 30 肖镜辉 统计语言模型简介
2007 5 30 肖镜辉 统计语言模型简介
xceman
 
PHP Unit-Testing With Doubles
PHP Unit-Testing With DoublesPHP Unit-Testing With Doubles
PHP Unit-Testing With Doubles
Mihail Irintchev
 
Stub you!
Stub you!Stub you!
Stub you!
Andrea Giuliano
 
デブサミ関西2012 B-3
デブサミ関西2012 B-3デブサミ関西2012 B-3
デブサミ関西2012 B-3
Koichi Sakata
 
PHPUnit でテスト駆動開発を始めよう
PHPUnit でテスト駆動開発を始めようPHPUnit でテスト駆動開発を始めよう
PHPUnit でテスト駆動開発を始めようYuya Takeyama
 
Awsで実現するseleniumテスト高速術
Awsで実現するseleniumテスト高速術Awsで実現するseleniumテスト高速術
Awsで実現するseleniumテスト高速術finoue
 
PHPUnit 入門介紹
PHPUnit 入門介紹PHPUnit 入門介紹
PHPUnit 入門介紹
Jace Ju
 
PHPUnit best practices presentation
PHPUnit best practices presentationPHPUnit best practices presentation
PHPUnit best practices presentation
Thanh Robi
 
テスト駆動開発へようこそ
テスト駆動開発へようこそテスト駆動開発へようこそ
テスト駆動開発へようこそ
Shuji Watanabe
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
Michelangelo van Dam
 
Jmeter Performance Testing
Jmeter Performance TestingJmeter Performance Testing
Jmeter Performance TestingAtul Pant
 
AspectMock 最強のモッキングフレームワーク
AspectMock 最強のモッキングフレームワークAspectMock 最強のモッキングフレームワーク
AspectMock 最強のモッキングフレームワーク
kenjis
 
Di – ioc (ninject)
Di – ioc (ninject)Di – ioc (ninject)
Di – ioc (ninject)
ZealousysDev
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
Mike Lively
 

Viewers also liked (20)

とある事業の脱レガシー
とある事業の脱レガシーとある事業の脱レガシー
とある事業の脱レガシー
 
5分でわかる? 関数型 PHP の潮流
5分でわかる? 関数型 PHP の潮流5分でわかる? 関数型 PHP の潮流
5分でわかる? 関数型 PHP の潮流
 
Ioc & in direction
Ioc & in directionIoc & in direction
Ioc & in direction
 
Good Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX PhilosophyGood Parts of PHP and the UNIX Philosophy
Good Parts of PHP and the UNIX Philosophy
 
UnitTestのためのクラス設計
UnitTestのためのクラス設計UnitTestのためのクラス設計
UnitTestのためのクラス設計
 
2007 5 30 肖镜辉 统计语言模型简介
2007 5 30 肖镜辉 统计语言模型简介2007 5 30 肖镜辉 统计语言模型简介
2007 5 30 肖镜辉 统计语言模型简介
 
IoC with PHP
IoC with PHPIoC with PHP
IoC with PHP
 
PHP Unit-Testing With Doubles
PHP Unit-Testing With DoublesPHP Unit-Testing With Doubles
PHP Unit-Testing With Doubles
 
Stub you!
Stub you!Stub you!
Stub you!
 
デブサミ関西2012 B-3
デブサミ関西2012 B-3デブサミ関西2012 B-3
デブサミ関西2012 B-3
 
PHPUnit でテスト駆動開発を始めよう
PHPUnit でテスト駆動開発を始めようPHPUnit でテスト駆動開発を始めよう
PHPUnit でテスト駆動開発を始めよう
 
Awsで実現するseleniumテスト高速術
Awsで実現するseleniumテスト高速術Awsで実現するseleniumテスト高速術
Awsで実現するseleniumテスト高速術
 
PHPUnit 入門介紹
PHPUnit 入門介紹PHPUnit 入門介紹
PHPUnit 入門介紹
 
PHPUnit best practices presentation
PHPUnit best practices presentationPHPUnit best practices presentation
PHPUnit best practices presentation
 
テスト駆動開発へようこそ
テスト駆動開発へようこそテスト駆動開発へようこそ
テスト駆動開発へようこそ
 
Introduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnitIntroduction to Unit Testing with PHPUnit
Introduction to Unit Testing with PHPUnit
 
Jmeter Performance Testing
Jmeter Performance TestingJmeter Performance Testing
Jmeter Performance Testing
 
AspectMock 最強のモッキングフレームワーク
AspectMock 最強のモッキングフレームワークAspectMock 最強のモッキングフレームワーク
AspectMock 最強のモッキングフレームワーク
 
Di – ioc (ninject)
Di – ioc (ninject)Di – ioc (ninject)
Di – ioc (ninject)
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
 

Similar to PHPUnit でよりよくテストを書くために

Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
Sam Hennessy
 
Oops in php
Oops in phpOops in php
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)
Arnaud Langlade
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
Win Yu
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
Rifat Nabi
 
Laravel
LaravelLaravel
Laravel
Sayed Ahmed
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
Rafael Dohms
 
BEAR DI
BEAR DIBEAR DI
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes
Azim Kurt
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
Barang CK
 
Presentation1
Presentation1Presentation1
Presentation1
Rahadyan Gusti
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2
eugenio pombi
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
Michelangelo van Dam
 
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
DevClub_lv
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
Michelangelo van Dam
 
Workshop unittesting
Workshop unittestingWorkshop unittesting
Workshop unittesting
Joshua Thijssen
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPWildan Maulana
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome Town
Ross Tuck
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your Code
Abbas Ali
 

Similar to PHPUnit でよりよくテストを書くために (20)

Adding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy ApplicationsAdding Dependency Injection to Legacy Applications
Adding Dependency Injection to Legacy Applications
 
Oops in php
Oops in phpOops in php
Oops in php
 
Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)Code moi une RH! (PHP tour 2017)
Code moi une RH! (PHP tour 2017)
 
PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)PHP 良好實踐 (Best Practice)
PHP 良好實踐 (Best Practice)
 
Dependency Injection
Dependency InjectionDependency Injection
Dependency Injection
 
Laravel
LaravelLaravel
Laravel
 
Your code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnConYour code sucks, let's fix it - DPC UnCon
Your code sucks, let's fix it - DPC UnCon
 
BEAR DI
BEAR DIBEAR DI
BEAR DI
 
Bacbkone js
Bacbkone jsBacbkone js
Bacbkone js
 
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
 
Presentation1
Presentation1Presentation1
Presentation1
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11
 
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
“SOLID principles in PHP – how to apply them in PHP and why should we care“ b...
 
Unit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBeneluxUnit testing with zend framework PHPBenelux
Unit testing with zend framework PHPBenelux
 
Workshop unittesting
Workshop unittestingWorkshop unittesting
Workshop unittesting
 
Object Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOPObject Oriented Programming with PHP 5 - More OOP
Object Oriented Programming with PHP 5 - More OOP
 
Command Bus To Awesome Town
Command Bus To Awesome TownCommand Bus To Awesome Town
Command Bus To Awesome Town
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your Code
 

More from Yuya Takeyama

Reactor Pattern and React
Reactor Pattern and ReactReactor Pattern and React
Reactor Pattern and ReactYuya Takeyama
 
PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)
PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)
PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)Yuya Takeyama
 
PHP と MySQL でカジュアルに MapReduce する (Short Version)
PHP と MySQL でカジュアルに MapReduce する (Short Version)PHP と MySQL でカジュアルに MapReduce する (Short Version)
PHP と MySQL でカジュアルに MapReduce する (Short Version)
Yuya Takeyama
 
PHP と MySQL でカジュアルに MapReduce する
PHP と MySQL でカジュアルに MapReduce するPHP と MySQL でカジュアルに MapReduce する
PHP と MySQL でカジュアルに MapReduce するYuya Takeyama
 
MySQL 入門的なはなし
MySQL 入門的なはなしMySQL 入門的なはなし
MySQL 入門的なはなしYuya Takeyama
 
HashTable と HashDos
HashTable と HashDosHashTable と HashDos
HashTable と HashDosYuya Takeyama
 
Proposal for xSpep BDD Framework for PHP
Proposal for xSpep BDD Framework for PHPProposal for xSpep BDD Framework for PHP
Proposal for xSpep BDD Framework for PHPYuya Takeyama
 
Building Development Environment with php-build and phpenv
Building Development Environment with php-build and phpenvBuilding Development Environment with php-build and phpenv
Building Development Environment with php-build and phpenvYuya Takeyama
 
LIMIT 付きで UPDATE を行うと何故怒られるか
LIMIT 付きで UPDATE を行うと何故怒られるかLIMIT 付きで UPDATE を行うと何故怒られるか
LIMIT 付きで UPDATE を行うと何故怒られるかYuya Takeyama
 
Ruby 同好会宣言
Ruby 同好会宣言Ruby 同好会宣言
Ruby 同好会宣言
Yuya Takeyama
 
第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)
第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)
第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)
Yuya Takeyama
 

More from Yuya Takeyama (13)

Reactor Pattern and React
Reactor Pattern and ReactReactor Pattern and React
Reactor Pattern and React
 
PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)
PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)
PHP と MySQL で 1 カチャカチャカチャ...ッターン! MapReduce (@ニコニコ超会議)
 
PHP と MySQL でカジュアルに MapReduce する (Short Version)
PHP と MySQL でカジュアルに MapReduce する (Short Version)PHP と MySQL でカジュアルに MapReduce する (Short Version)
PHP と MySQL でカジュアルに MapReduce する (Short Version)
 
PHP と MySQL でカジュアルに MapReduce する
PHP と MySQL でカジュアルに MapReduce するPHP と MySQL でカジュアルに MapReduce する
PHP と MySQL でカジュアルに MapReduce する
 
MySQL 入門的なはなし
MySQL 入門的なはなしMySQL 入門的なはなし
MySQL 入門的なはなし
 
HashTable と HashDos
HashTable と HashDosHashTable と HashDos
HashTable と HashDos
 
Proposal for xSpep BDD Framework for PHP
Proposal for xSpep BDD Framework for PHPProposal for xSpep BDD Framework for PHP
Proposal for xSpep BDD Framework for PHP
 
Building Development Environment with php-build and phpenv
Building Development Environment with php-build and phpenvBuilding Development Environment with php-build and phpenv
Building Development Environment with php-build and phpenv
 
Making DSL with []
Making DSL with []Making DSL with []
Making DSL with []
 
LIMIT 付きで UPDATE を行うと何故怒られるか
LIMIT 付きで UPDATE を行うと何故怒られるかLIMIT 付きで UPDATE を行うと何故怒られるか
LIMIT 付きで UPDATE を行うと何故怒られるか
 
GOOS #1
GOOS #1GOOS #1
GOOS #1
 
Ruby 同好会宣言
Ruby 同好会宣言Ruby 同好会宣言
Ruby 同好会宣言
 
第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)
第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)
第一回 社内勉強会 PHP Application Security Checklist に学ぶ PHP セキュリティ (Excerpt)
 

Recently uploaded

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 

Recently uploaded (20)

DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 

PHPUnit でよりよくテストを書くために

  • 1.
  • 2.
  • 3.
  • 4. ['begin', ['define', 'fib', ['lambda', ['x'], ['if', ['<', ':x', 2], ':x', ['+', ['fib', ['-', ':x', 2]], ['fib', ['-', ':x', 1]]]]]], ['print', 'fib(10) = '], ['println', ['fib', 10]]] => fib(10) = 55
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. class CalculatorTest extends PHPUnit_Framework_TestCase {     public function setUp()     {         $this->calc = new Calculator;     }     public function test_add_ ()     {         $result = $this->calc->add(1, 2);         $this->assertSame(3, $result);     } }
  • 11. class CalculatorTest extends PHPUnit_Framework_TestCase {     public function setUp()     {         $this->calc = new Calculator;     }     public function test_add_ ()     {         $result = $this->calc->add(1, 2);         $this->assertSame(3, $result);     } }
  • 12. class CalculatorTest extends PHPUnit_Framework_TestCase {     public function setUp()     {         $this->calc = new Calculator;     }     public function test_add_ ()     {         $result = $this->calc->add(1, 2);         $this->assertSame(3, $result);     } }
  • 13. class CalculatorTest extends PHPUnit_Framework_TestCase {     public function setUp()     {         $this->calc = new Calculator;     }     public function test_add_ ()     {         $result = $this->calc->add(1, 2);         $this->assertSame(3, $result);     } }
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. public function test_isValid_ true() {     $user = new User;     $user->setName('Yuya');     $user->setUrl('http://yuyat.jp/');     $user->setAge(24);     $this->assertTrue($user->isValid()); } public function test_isValid_ false() {     $user = new User;     $user->setName('Yuya');     $user->setUrl('http://yuyat.jp/');     $user->setAge(NULL);     $this->assertFalse($user->isValid()); }
  • 26. public function test_isValid_ true() {     $user = new User;     $user->setName('Yuya');     $user->setUrl('http://yuyat.jp/');     $user->setAge(24);     $this->assertTrue($user->isValid()); } public function test_isValid_ false() {     $user = new User;     $user->setName('Yuya');     $user->setUrl('http://yuyat.jp/');     $user->setAge(NULL);     $this->assertFalse($user->isValid()); }
  • 27. public function test_isValid_ true() {     $user = $this->createValidUser();     $this->assertTrue($user->isValid()); } public function test_isValid_ false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid()); }
  • 28. public function test_isValid_ true() {     $user = $this->createValidUser();     $this->assertTrue($user->isValid()); } public function test_isValid_ false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid()); }
  • 29. public function test_isValid_ true() {     $user = $this->createValidUser();     $this->assertTrue($user->isValid()); } public function test_isValid_ false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid()); }
  • 30.
  • 31. public function test_isValid_ false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid());     $user = $this->createValidUser();     $user->setName(NULL);     $this->assertFalse($user->isValid()); }
  • 32. public function test_isValid_ false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid());     $user = $this->createValidUser();     $user->setName(NULL);     $this->assertFalse($user->isValid()); }
  • 33. public function test_isValid_ false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid());     $user = $this->createValidUser();     $user->setName(NULL);     $this->assertFalse($user->isValid()); }
  • 34. public function test_isValid_ Null false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid()); } public function test_isValid_ Null false() {     $user = $this->createValidUser();     $user->setName(NULL);     $this->assertFalse($user->isValid()); }
  • 35. public function test_isValid_ Null false() {     $user = $this->createValidUser();     $user->setAge(NULL);     $this->assertFalse($user->isValid()); } public function test_isValid_ Null false() {     $user = $this->createValidUser();     $user->setName(NULL);     $this->assertFalse($user->isValid()); }
  • 36.
  • 37.
  • 38.
  • 39. class Request {     public function isSsl()     {         return $_SERVER['HTTPS'] === 'on';     } }
  • 40. class Request {     public function isSsl()     {         return $_SERVER['HTTPS'] === 'on';     } }
  • 41. public function test_isSsl_HTTPS true() {     $_SERVER['HTTPS'] = 'on';     $this->assertTrue($this->request->isSsl()); } public function test_isSsl_HTTPS false() {     unset($_SERVER['HTTPS']);     $this->assertFalse($this->request->isSsl()); }
  • 42. public function test_isSsl_HTTPS true() {     $_SERVER['HTTPS'] = 'on';     $this->assertTrue($this->request->isSsl()); } public function test_isSsl_HTTPS false() {     unset($_SERVER['HTTPS']);     $this->assertFalse($this->request->isSsl()); }
  • 43. public function test_isSsl_HTTPS true() {     $_SERVER['HTTPS'] = 'on';     $this->assertTrue($this->request->isSsl()); } public function test_isSsl_HTTPS false() {     unset($_SERVER['HTTPS']);     $this->assertFalse($this->request->isSsl()); }
  • 44. public function test_isSsl_HTTPS true() {     $_SERVER['HTTPS'] = 'on';     $this->assertTrue($this->request->isSsl()); } public function test_isSsl_HTTPS false() {     unset($_SERVER['HTTPS']);     $this->assertFalse($this->request->isSsl()); }
  • 45. class Request { public function __construct($server) {      $this->_server = $server; } public function isSsl() {      return $this->_server === 'on'; } }
  • 46. class Request { public function __construct($server) {      $this->_server = $server; } public function isSsl() {      return $this->_server === 'on'; } }
  • 47. public function test_isSsl_HTTPS true() {     $request = new Request(array('HTTPS' => 'on'));     $this->assertTrue($request->isSsl()); } public function test_isSsl_HTTPS false() {     $request = new Request(array());     $this->assertFalse($request->isSsl()); }
  • 48. public function test_isSsl_HTTPS true() {     $request = new Request(array('HTTPS' => 'on'));     $this->assertTrue($request->isSsl()); } public function test_isSsl_HTTPS false() {     $request = new Request(array());     $this->assertFalse($request->isSsl()); }
  • 49.
  • 50.
  • 51. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ }     public static function findByName($name) { /*~*/ }     public function save() { /*~*/ } }
  • 53. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ } } class UserMapper {     public function findByName($name) { /*~*/ }     public function save(User $user) { /*~*/ } }
  • 54. $mapper = new UserMapper; $user = $mapper->findByName('Bob'); $user->setName('Alice'); $mapper->save($user);
  • 55. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ }     public static function findByName($name) { /*~*/ }     public function save() { /*~*/ } }
  • 56. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ }     public static function findByName($name) { /*~*/ }     public function save() { /*~*/ } }
  • 57. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ }     public static function findByName($name) { /*~*/ }     public function save() { /*~*/ } }
  • 58. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ }     public static function findByName($name) { /*~*/ }     public function save() { /*~*/ } }
  • 59. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ } } class UserMapper {     public function findByName($name) { /*~*/ }     public function save(User $user) { /*~*/ } }
  • 60. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ } } class UserMapper {     public function findByName($name) { /*~*/ }     public function save(User $user) { /*~*/ } }
  • 61. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ } } class UserMapper {     public function findByName($name) { /*~*/ }     public function save(User $user) { /*~*/ } }
  • 62. class User {     protected $_name;     protected $_birthday;     public function setName($name) { /*~*/ }     public function getName() { /*~*/ }     public function getAge() { /*~*/ } } class UserMapper {     public function findByName($name) { /*~*/ }     public function save(User $user) { /*~*/ } }
  • 63. class Config {     protected static $_instance;     private function __construct() {}     public static function getInstance()     {         if (empty(self::$_instance)) {             self::$_instance = new self;         }         return self::$_instance;     } }
  • 64. public function __clone() {     throw new BadMethodCallException( 'Clone is not allowed.' ); }
  • 65. public function test_get_ () {     $config = Config::getInstance();     $config->set('message', 'Hello');     $this->assertSame( 'Hello', $config->get('message') ); }
  • 66. public function test_get_ Null() {     $config = Config::getInstance();     $this->assertNull( $config->get('message') ); }
  • 67. public function test_get_ Null() {     $config = Config::getInstance();     $this->assertNull( $config->get('message') ); }
  • 68. public function test_get_ Null() {     $config = Config::getInstance();     $config->init();     $this->assertNull( $config->get('message') ); }
  • 69. public function test_get_ Null() {     $config = Config::getInstance();     $config->init();     $this->assertNull( $config->get('message') ); }
  • 70. public function test_get_ Null() {     $config = Config::getInstance();     $config->init();     $this->assertNull( $config->get('message') ); }