SlideShare une entreprise Scribd logo
1  sur  77
Télécharger pour lire hors ligne
['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 でよりよくテストを書くために

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

とある事業の脱レガシー
とある事業の脱レガシーとある事業の脱レガシー
とある事業の脱レガシー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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus de 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
 

Plus de 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)
 

Dernier

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 

Dernier (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 

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') ); }