SlideShare una empresa de Scribd logo
1 de 77
Descargar para leer sin conexión
['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 でよりよくテストを書くために

Más contenido relacionado

La actualidad más candente

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
 

La actualidad más candente (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
 

Destacado

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

Destacado (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 a 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 a 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
 

Más 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
 

Más 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)
 

Último

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 

Último (20)

Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 

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