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 PHPersistenceHugo Hamon
 
Silex meets SOAP & REST
Silex meets SOAP & RESTSilex meets SOAP & REST
Silex meets SOAP & RESTHugo 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 DICKonstantin 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 CalisthenicsGuilherme 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 PimpleHugo Hamon
 
Database Design Patterns
Database Design PatternsDatabase Design Patterns
Database Design PatternsHugo 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 TriviaNikita 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
 
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 / XSolveXSolve
 
Introdução ao Perl 6
Introdução ao Perl 6Introdução ao Perl 6
Introdução ao Perl 6garux
 
R57shell
R57shellR57shell
R57shellady36
 
Electrify your code with PHP Generators
Electrify your code with PHP GeneratorsElectrify your code with PHP Generators
Electrify your code with PHP GeneratorsMark Baker
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHPMarcello 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 clienteLeonardo 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
 

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 PhilosophyYuya 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 DoublesMihail Irintchev
 
デブサミ関西2012 B-3
デブサミ関西2012 B-3デブサミ関西2012 B-3
デブサミ関西2012 B-3Koichi 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 presentationThanh 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 PHPUnitMichelangelo 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 TestingMike 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 ApplicationsSam Hennessy
 
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 InjectionRifat Nabi
 
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 UnConRafael Dohms
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutesBarang CK
 
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 MinutesAzim Kurt
 
PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2PHPUnit elevato alla Symfony2
PHPUnit elevato alla Symfony2eugenio pombi
 
Unit testing with zend framework tek11
Unit testing with zend framework tek11Unit testing with zend framework tek11
Unit testing with zend framework tek11Michelangelo 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 PHPBeneluxMichelangelo van Dam
 
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 TownRoss Tuck
 
Tidy Up Your Code
Tidy Up Your CodeTidy Up Your Code
Tidy Up Your CodeAbbas 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
 
laravel tricks in 50minutes
laravel tricks in 50minuteslaravel tricks in 50minutes
laravel tricks in 50minutes
 
50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes50 Laravel Tricks in 50 Minutes
50 Laravel Tricks in 50 Minutes
 
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

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
 
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.pdfFIDO Alliance
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
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.pdfFIDO Alliance
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
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 ParametersSafe Software
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
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.pdfCheryl Hung
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
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
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsVlad Stirbu
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
 
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)

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*
 
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
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
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
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
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
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
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
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
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...
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
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') ); }