The document provides guidance on test-driven development and unit testing. It discusses the goals of testing such as finding bugs, enabling refactoring, documenting code behavior, and detecting design issues. It also covers best practices for tests, including keeping them independent of implementation, predictable, fast, and simple to implement. Specific testing tools and frameworks mentioned include PHPUnit and Prophecy. The anatomy of a test is explained as Arrange, Act, Assert (or Given, When, Then). Examples are given of unit tests for a Serveur class using these concepts and frameworks.
The document discusses unit testing Zend Framework applications. It provides an overview of setting up PHPUnit for testing, including creating a phpunit.xml file and TestHelper bootstrap file. It also discusses testing Zend Forms and Models, including writing tests to validate form data and test that models are empty on construction. Code examples are provided for writing tests for a CommentForm and CommentModel class.
The document discusses unit testing Zend Framework applications. It begins by explaining the importance of testing and some common excuses for not testing. It then provides examples of setting up PHPUnit configuration and bootstrap files for testing Zend Framework applications. The document demonstrates how to write tests for Zend Forms and models, including testing with both valid and invalid data. It shows how to modify models to add validation filters and validators.
Replacing dependents with doubles is a central part of testing that every developer has to master. This talk goes over the different types of doubles and explains their place in testing, how to implement them in a mainstream mocking framework, and which strategies or doubles to use in different message exchange scenarios between objects. After this talk you will have moved a step forward in your understanding of testing in the context of object oriented programming.
The document discusses the concept of Object Calisthenics, which are programming guidelines aimed at writing better object-oriented code. It specifically outlines 9 guidelines/rules adapted for PHP programming:
1. Only one level of indentation per method.
2. Do not use the 'else' keyword.
3. Wrap all primitive data types and strings in objects.
4. Collections of objects should be first-class objects.
5. Only call one method on an object per line.
6. Do not abbreviate names.
7. Keep classes small with under 200 lines of code and 10 methods.
8. Limit the number of instance variables in a class to 2-5.
9
Selenide - популярная библиотека для написания лаконичных и стабильных UI-тестов на Java. Многие используют её для тестирования веб-приложения, но не все знают, что её также можно использовать и для мобилок.
Рассказ о том, как использовать Selenide для тестирования веба и мобилок и даже переиспользовать код между ними.
This document discusses unit testing and the use of stubs and mocks. It provides examples of how to create stub and mock objects using Phake, a PHP mocking framework. Stub objects are pre-programmed to return expected values during tests, while mock objects also allow for verifying that expected methods were called with the correct parameters. The document shows how to stub and mock method calls, magic methods, and verify invocation counts and order using Phake.
Presentation made at GTA meetup in 2012-02-07.
Object Calisthenics is a set of exercise rules to reach better code, maintainable, testable and readable.
This document discusses mocking dependencies in PHPUnit tests. It begins by defining dependencies and dependency injection, and why it is important to mock dependencies in unit tests. It then covers defining test doubles like mocks, stubs, and dummies to simulate dependencies. Various examples are provided for mocking different types of dependencies, like APIs, databases, and external data sources. The goal of mocking is to test units of code in isolation without relying on other components, in order to make tests faster and more reliable.
The document discusses unit testing Zend Framework applications. It provides an overview of setting up PHPUnit for testing, including creating a phpunit.xml file and TestHelper bootstrap file. It also discusses testing Zend Forms and Models, including writing tests to validate form data and test that models are empty on construction. Code examples are provided for writing tests for a CommentForm and CommentModel class.
The document discusses unit testing Zend Framework applications. It begins by explaining the importance of testing and some common excuses for not testing. It then provides examples of setting up PHPUnit configuration and bootstrap files for testing Zend Framework applications. The document demonstrates how to write tests for Zend Forms and models, including testing with both valid and invalid data. It shows how to modify models to add validation filters and validators.
Replacing dependents with doubles is a central part of testing that every developer has to master. This talk goes over the different types of doubles and explains their place in testing, how to implement them in a mainstream mocking framework, and which strategies or doubles to use in different message exchange scenarios between objects. After this talk you will have moved a step forward in your understanding of testing in the context of object oriented programming.
The document discusses the concept of Object Calisthenics, which are programming guidelines aimed at writing better object-oriented code. It specifically outlines 9 guidelines/rules adapted for PHP programming:
1. Only one level of indentation per method.
2. Do not use the 'else' keyword.
3. Wrap all primitive data types and strings in objects.
4. Collections of objects should be first-class objects.
5. Only call one method on an object per line.
6. Do not abbreviate names.
7. Keep classes small with under 200 lines of code and 10 methods.
8. Limit the number of instance variables in a class to 2-5.
9
Selenide - популярная библиотека для написания лаконичных и стабильных UI-тестов на Java. Многие используют её для тестирования веб-приложения, но не все знают, что её также можно использовать и для мобилок.
Рассказ о том, как использовать Selenide для тестирования веба и мобилок и даже переиспользовать код между ними.
This document discusses unit testing and the use of stubs and mocks. It provides examples of how to create stub and mock objects using Phake, a PHP mocking framework. Stub objects are pre-programmed to return expected values during tests, while mock objects also allow for verifying that expected methods were called with the correct parameters. The document shows how to stub and mock method calls, magic methods, and verify invocation counts and order using Phake.
Presentation made at GTA meetup in 2012-02-07.
Object Calisthenics is a set of exercise rules to reach better code, maintainable, testable and readable.
This document discusses mocking dependencies in PHPUnit tests. It begins by defining dependencies and dependency injection, and why it is important to mock dependencies in unit tests. It then covers defining test doubles like mocks, stubs, and dummies to simulate dependencies. Various examples are provided for mocking different types of dependencies, like APIs, databases, and external data sources. The goal of mocking is to test units of code in isolation without relying on other components, in order to make tests faster and more reliable.
PHPUnit is a test suite framework that is widely used for PHP projects. It provides improvements over older testing frameworks like SimpleTest, including better command line tools, code coverage reports, assertions, mock objects, and tool chain support. PHPUnit uses annotations and assertions to make tests stricter and more consistent. It supports features like fixtures, mock objects, and code coverage reporting to help test codebases thoroughly. PHPUnit can be run from the command line or a web interface, and integrates with continuous integration servers to run tests automatically.
This document discusses using CakePHP to develop an e-commerce application that integrates with Amazon's APIs. It describes extending CakePHP controllers and models to work with Amazon data, using ClassRegistry to initialize models within models' constructors, and testing with a custom database configuration for the Amazon data source. Key classes and behaviors are extended, and a class registry pattern is implemented to reduce duplication and improve organization.
This document provides information about a CakePHP workshop including the presenter, development environment setup instructions, and an overview of the workshop content. Some key points:
- The presenter is Walther Lalk, a CakePHP core team member.
- Instructions are provided for setting up a development environment using Vagrant or the built-in PHP server.
- The workshop will cover installing CakePHP, baking a database and entities, authentication, authorization, and using CRUD to generate basic CRUD functionality.
- Attendees will build an events application with members, events, and event attendance tracking. Security, validation, and associations between entities will be implemented.
- CRUD will be
Software development is riddled with explicit and implicit costs. Every decision you make has a cost attached to it. When you're writing code, you're making an investment, the size of which will for a long time define the costs of your future growth. Making right decision about these investments is very tricky and the cost of wrong decisions might be crippling for both business and teams that support it.
Extreme Programming and Test Driven Development in particular are practices that are aiming at supporting development effort by making it easier to introduce change. That said, sometimes those tools can become a problem of its own when applied in the wrong way or for the wrong context. Understanding software cost forces is a very important skill of successful teams and something that helps understand how to apply XP and TDD in different contexts.
How do you create applications with an incredible level of extendability without losing readability in the process? What if there's a way to separate concerns not only on the code, but on the service definition level? This talk will explore structural and behavioural patterns and ways to enrich them through tricks of powerful dependency injection containers such as Symfony2 DIC component.
The document discusses test driven development (TDD). It covers the evolution of testing, automated testing, and the motivations and principles of TDD. The main points of TDD are covered, including writing a test first that fails, then writing code to make the test pass, and refactoring the code. An interactive session demonstrates applying TDD to developing a task list application, including tests for title, ID, completion status, and saving tasks to a database. The importance of covering variations with tests and the risks of focusing only on 100% test coverage are also discussed.
The document discusses best practices for testing software applications. It covers topics like writing testable code through techniques like dependency injection, using different types of tests like unit tests and functional tests, and strategies for testing like the four phase test approach of fixture setup, test execution, result verification, and fixture teardown. Fake objects and mocks are presented as ways to replace slow dependencies for isolated testing.
The document discusses the importance of unit testing and describes how developers are returning to write good tests after cutting corners during economic difficulties. It provides examples of unit tests being written for an order management system using PHPUnit to test the createOrder method by mocking dependencies and asserting the return value.
This document contains a summary of jQuery secrets presented by Bastian Feder. It discusses various techniques including saving and removing state from DOM elements using jQuery.data() and jQuery.removeData(), extending jQuery functionality through plugins, and customizing AJAX requests and event handling. The presentation provides code examples for working with jQuery's data storage methods, namespaces, promises/deferreds, global AJAX settings, and extending jQuery.
This document discusses deploying code directly to production using a "scientist approach" with experiments. It introduces the Scientist framework, which allows refactoring and improving existing code in a live environment without risk. Scientist experiments allow running a control and trials to gradually change a system. Branch by abstraction is described as a technique to make large changes gradually while continuing regular releases. The document provides examples using Scientist experiments to refactor validation logic in a production system.
A lot of people using PHPunit for testing their source code. While I was observing my team I recognized most of them are only using the standard assertions like 'assertEquals()' and are complaining about how hard it is to test the code even when the tests are written first. This talk is about all the stuff not used on a daily basis and it digs deep into uncommon features of PHPUnit.
Everything You (N)ever Wanted to Know about Testing View ControllersBrian Gesiak
This document discusses testing view controllers in iOS applications. It outlines three key aspects for testing view controllers: 1) Defining a module for the app, 2) Manually triggering view controller lifecycle events, and 3) Accessing view controllers instantiated from a storyboard. The document provides examples of writing tests that instantiate a view controller, trigger viewDidLoad, and assert properties and behaviors. While more difficult than testing model layers, the document argues it is possible and important to test view controllers with the right techniques.
The document discusses the benefits of CoffeeScript compared to JavaScript. It provides examples of cleaner CoffeeScript syntax for functions, loops, and list comprehensions compared to their JavaScript equivalents. Overall, CoffeeScript code is more concise and readable than plain JavaScript code.
The document contains code for unit testing a PHP MVC application using PHPUnit. It includes:
- Code for the Todo model and its tests using PHPUnit assertions.
- Configuration for PHPUnit to run tests for the application and library.
- Tests for the IndexController using a Test_ControllerTestCase class with helper methods.
- Code for Request, Response and View classes to mock the MVC framework.
- A test to interact with the application interface using Selenium.
The document shows the project structure for an MVC application and library with tests. It demonstrates how to test models, controllers and the user interface using test doubles, assertions and helper methods in PHPUnit.
Testing view controllers with Quick and NimbleMarcio Klepacz
The document discusses testing view controllers with Quick and Nimble. It provides an example of testing a view controller that presents an app intro screen using behavior-driven development. Specifically, it shows how to arrange the view controller in a testable state, invoke the code being tested, and make assertions about the expected behavior using Quick and Nimble matchers. The tests verify that the app intro is presented if it has not been dismissed before and is dismissed if the dismiss button is tapped, as well as checking that a flag is set correctly. Following the arrange-act-assert pattern and addressing view controller lifecycle issues are emphasized for effective testing.
By the sum of PHPUnit assertion power and Symfony2 functional testing tools the developer can obtain a deep control on the developed application.
Here you can find some suggestions on how to leverage that power.
As presented at Dutch PHP Conference 2015, an introduction to command buses, how to implement your own in PHP and why they're both useful but unimportant.
1. The document discusses strategies for optimizing software costs, including the costs of introduction, change, and ownership over the lifetime of a project.
2. It emphasizes focusing on optimizing for cost of introduction early on, as this cost is relatively easy to optimize and loses relevance over time. However, cost of change increases exponentially and is most important to optimize for longer-term projects.
3. Cost of ownership involves ongoing maintenance and allows balancing the costs of introduction and change by selectively taking ownership of only necessary logic through techniques like testing and refactoring.
This document discusses mocking dependencies in PHPUnit tests. It begins by defining dependencies and dependency injection, explaining that unit tests should isolate the code being tested. It then covers defining test doubles like mocks, stubs, and dummies to simulate dependencies. Specific examples are given for mocking objects, database queries using PDO, and external APIs. The document emphasizes that dependency injection improves testability and dependencies should only be mocked as needed. The goal of mocking is to write better isolated tests that don't rely on external factors.
Presentation of the command dispatcher pattern I made during one of the chapter meetings in HelloFresh.
Companion article: https://olvlvl.com/2018-04-command-dispatcher-pattern
PHPUnit is a test suite framework that is widely used for PHP projects. It provides improvements over older testing frameworks like SimpleTest, including better command line tools, code coverage reports, assertions, mock objects, and tool chain support. PHPUnit uses annotations and assertions to make tests stricter and more consistent. It supports features like fixtures, mock objects, and code coverage reporting to help test codebases thoroughly. PHPUnit can be run from the command line or a web interface, and integrates with continuous integration servers to run tests automatically.
This document discusses using CakePHP to develop an e-commerce application that integrates with Amazon's APIs. It describes extending CakePHP controllers and models to work with Amazon data, using ClassRegistry to initialize models within models' constructors, and testing with a custom database configuration for the Amazon data source. Key classes and behaviors are extended, and a class registry pattern is implemented to reduce duplication and improve organization.
This document provides information about a CakePHP workshop including the presenter, development environment setup instructions, and an overview of the workshop content. Some key points:
- The presenter is Walther Lalk, a CakePHP core team member.
- Instructions are provided for setting up a development environment using Vagrant or the built-in PHP server.
- The workshop will cover installing CakePHP, baking a database and entities, authentication, authorization, and using CRUD to generate basic CRUD functionality.
- Attendees will build an events application with members, events, and event attendance tracking. Security, validation, and associations between entities will be implemented.
- CRUD will be
Software development is riddled with explicit and implicit costs. Every decision you make has a cost attached to it. When you're writing code, you're making an investment, the size of which will for a long time define the costs of your future growth. Making right decision about these investments is very tricky and the cost of wrong decisions might be crippling for both business and teams that support it.
Extreme Programming and Test Driven Development in particular are practices that are aiming at supporting development effort by making it easier to introduce change. That said, sometimes those tools can become a problem of its own when applied in the wrong way or for the wrong context. Understanding software cost forces is a very important skill of successful teams and something that helps understand how to apply XP and TDD in different contexts.
How do you create applications with an incredible level of extendability without losing readability in the process? What if there's a way to separate concerns not only on the code, but on the service definition level? This talk will explore structural and behavioural patterns and ways to enrich them through tricks of powerful dependency injection containers such as Symfony2 DIC component.
The document discusses test driven development (TDD). It covers the evolution of testing, automated testing, and the motivations and principles of TDD. The main points of TDD are covered, including writing a test first that fails, then writing code to make the test pass, and refactoring the code. An interactive session demonstrates applying TDD to developing a task list application, including tests for title, ID, completion status, and saving tasks to a database. The importance of covering variations with tests and the risks of focusing only on 100% test coverage are also discussed.
The document discusses best practices for testing software applications. It covers topics like writing testable code through techniques like dependency injection, using different types of tests like unit tests and functional tests, and strategies for testing like the four phase test approach of fixture setup, test execution, result verification, and fixture teardown. Fake objects and mocks are presented as ways to replace slow dependencies for isolated testing.
The document discusses the importance of unit testing and describes how developers are returning to write good tests after cutting corners during economic difficulties. It provides examples of unit tests being written for an order management system using PHPUnit to test the createOrder method by mocking dependencies and asserting the return value.
This document contains a summary of jQuery secrets presented by Bastian Feder. It discusses various techniques including saving and removing state from DOM elements using jQuery.data() and jQuery.removeData(), extending jQuery functionality through plugins, and customizing AJAX requests and event handling. The presentation provides code examples for working with jQuery's data storage methods, namespaces, promises/deferreds, global AJAX settings, and extending jQuery.
This document discusses deploying code directly to production using a "scientist approach" with experiments. It introduces the Scientist framework, which allows refactoring and improving existing code in a live environment without risk. Scientist experiments allow running a control and trials to gradually change a system. Branch by abstraction is described as a technique to make large changes gradually while continuing regular releases. The document provides examples using Scientist experiments to refactor validation logic in a production system.
A lot of people using PHPunit for testing their source code. While I was observing my team I recognized most of them are only using the standard assertions like 'assertEquals()' and are complaining about how hard it is to test the code even when the tests are written first. This talk is about all the stuff not used on a daily basis and it digs deep into uncommon features of PHPUnit.
Everything You (N)ever Wanted to Know about Testing View ControllersBrian Gesiak
This document discusses testing view controllers in iOS applications. It outlines three key aspects for testing view controllers: 1) Defining a module for the app, 2) Manually triggering view controller lifecycle events, and 3) Accessing view controllers instantiated from a storyboard. The document provides examples of writing tests that instantiate a view controller, trigger viewDidLoad, and assert properties and behaviors. While more difficult than testing model layers, the document argues it is possible and important to test view controllers with the right techniques.
The document discusses the benefits of CoffeeScript compared to JavaScript. It provides examples of cleaner CoffeeScript syntax for functions, loops, and list comprehensions compared to their JavaScript equivalents. Overall, CoffeeScript code is more concise and readable than plain JavaScript code.
The document contains code for unit testing a PHP MVC application using PHPUnit. It includes:
- Code for the Todo model and its tests using PHPUnit assertions.
- Configuration for PHPUnit to run tests for the application and library.
- Tests for the IndexController using a Test_ControllerTestCase class with helper methods.
- Code for Request, Response and View classes to mock the MVC framework.
- A test to interact with the application interface using Selenium.
The document shows the project structure for an MVC application and library with tests. It demonstrates how to test models, controllers and the user interface using test doubles, assertions and helper methods in PHPUnit.
Testing view controllers with Quick and NimbleMarcio Klepacz
The document discusses testing view controllers with Quick and Nimble. It provides an example of testing a view controller that presents an app intro screen using behavior-driven development. Specifically, it shows how to arrange the view controller in a testable state, invoke the code being tested, and make assertions about the expected behavior using Quick and Nimble matchers. The tests verify that the app intro is presented if it has not been dismissed before and is dismissed if the dismiss button is tapped, as well as checking that a flag is set correctly. Following the arrange-act-assert pattern and addressing view controller lifecycle issues are emphasized for effective testing.
By the sum of PHPUnit assertion power and Symfony2 functional testing tools the developer can obtain a deep control on the developed application.
Here you can find some suggestions on how to leverage that power.
As presented at Dutch PHP Conference 2015, an introduction to command buses, how to implement your own in PHP and why they're both useful but unimportant.
1. The document discusses strategies for optimizing software costs, including the costs of introduction, change, and ownership over the lifetime of a project.
2. It emphasizes focusing on optimizing for cost of introduction early on, as this cost is relatively easy to optimize and loses relevance over time. However, cost of change increases exponentially and is most important to optimize for longer-term projects.
3. Cost of ownership involves ongoing maintenance and allows balancing the costs of introduction and change by selectively taking ownership of only necessary logic through techniques like testing and refactoring.
This document discusses mocking dependencies in PHPUnit tests. It begins by defining dependencies and dependency injection, explaining that unit tests should isolate the code being tested. It then covers defining test doubles like mocks, stubs, and dummies to simulate dependencies. Specific examples are given for mocking objects, database queries using PDO, and external APIs. The document emphasizes that dependency injection improves testability and dependencies should only be mocked as needed. The goal of mocking is to write better isolated tests that don't rely on external factors.
Presentation of the command dispatcher pattern I made during one of the chapter meetings in HelloFresh.
Companion article: https://olvlvl.com/2018-04-command-dispatcher-pattern
This document introduces PHPSpec, a BDD framework for PHP inspired by RSpec. It discusses the principles of behavior-driven development (BDD) and test-driven development (TDD), and how PHPSpec implements a domain-specific language (DSL) that allows developers to write specifications in a natural language style. The document provides examples of how to write PHPSpec specifications using its matchers and contexts, run the specifications, and handle pending and failing tests. It also briefly discusses related tools like mocks, screen scraping with Goutte, and how BDD fits into the development cycle.
Watch Erik's presentation on PHP Unit Testing to gain familiarity with unit tests and unit testing here at Tagged, with the testing framework currently in place and also learn how to write (better) unit tests. Download his slides here or email him at ejohannessen@tagged.com.
You must’ve heard of Unit testing… If not, then this talk is definitely for you! If you do know Unit testing, you probably ran at some point into a hurdle: “Where do I start?” And despite your best efforts, you end up not having enough tests for your application – Then that change request comes in, requiring you to change that very same complex piece of code for which you are lacking tests! How do you going refactor while maintaining all those ‘undocumented’ business rules? This talk will show how Codeception can be leveraged to refactor the visuals aspects of an application, maintaining backwards compatibility on API changes and even assist in moving to a whole different server infrastructure.
The document defines a fib function that recursively calculates Fibonacci numbers and prints the 10th Fibonacci number. It then defines some unit tests for a Calculator class that test the add method by asserting the expected result. Finally, it defines some unit tests for a User class that test validating a user object.
The document discusses API design in PHP for the Ning platform. It covers how the PHP API provides an interface to the Ning REST APIs, which are used for content storage, user profiles, tagging, search, and more. Examples are given of using the PHP XN_Content class to create and save content to the REST API. The document emphasizes designing APIs that promote predictability, stability, and human performance over computer performance.
This document discusses PHPSpec, a behavior-driven development (BDD) framework for PHP. It begins by explaining what PHPSpec is and how it implements BDD through a domain-specific language (DSL) based on RSpec. The document then covers how PHPSpec specifies tests using contexts, examples, expectations, matchers, mocks, and stubs. It provides examples of writing PHPSpec tests and using various PHPSpec features. The document concludes by mentioning upcoming PHPSpec features and linking to resources for learning more.
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitsmueller_sandsmedia
PHPUnit provides many features beyond just testing code including:
- Command line options like --testdox to generate styled reports and --filter to select specific tests.
- Annotations like @covers and @group to document and organize tests.
- Various assertion methods like assertContains(), assertType(), and assertSelectRegExp() to validate test conditions.
- Test listeners that get called at different test execution stages to add functionality.
- Ways to test exceptions like @expectedException and try/catch blocks.
- Mocking features to isolate tests from external dependencies using callbacks and return values.
This document introduces unit testing with PHPUnit. It discusses what unit testing is, why it's important, and tools like SimpleTest and PHPUnit. It provides examples of basic unit tests for a HelloWorld class using PHPUnit. It also covers more advanced testing techniques like data providers, expected exceptions, fixtures, doubles, mocks, stubs, and database testing using examples like testing a BankAccount class. The document provides hints and tips for unit testing MVC frameworks like Zend Framework.
This document provides an overview of what JavaScript capabilities are available in Plone and how to use them. It discusses nuts and bolts topics like injecting JavaScript and CSS, as well as how to create common interactive elements like validation, popups, tabs, and drag and drop functionality using tools like jQuery. The document is intended as an introduction for Plone developers on getting started with JavaScript in Plone.
Presentation showing that writing tests is not really hard with examples on testing a simple class, testing with dataproviders, fixtures, mocks, stubs, databases and how to use zend framework bootstrap for MVC testing.
Given at php|tek 09 unconf sessions.
This document discusses unit testing PHP code with PHPUnit. It begins with an introduction to the speaker and then covers why testing is important, how to get started with PHPUnit, writing basic tests for a sample class, using features like data providers and expecting exceptions, and more advanced topics like stubs, mocks and testing databases and Zend Framework applications. The overall message is that testing is crucial for any PHP project and PHPUnit makes it easy to start writing tests.
What should you test with your unit tests? Some people will say that unit behaviour is best tested through it's outcomes. But what if communication between units itself is more important than the results of it? This session will introduce you to two different ways of unit-testing and show you a way to assert your object behaviours through their communications.
In 2010, I told everyone how to start unit testing Zend Framework applications. In 2011, let’s take this a step further by testing services, work flows and performance. Looking to raise the bar on quality? Let this talk be the push you need to improve your Zend Framework projects.
Testing applications is one of the most important thing in a developer’s toolbox.
Sometime writing tests is not so straightforward and as time goes by you notice that you have to maintain your application and your tests too.
The purpose of this talk is to show how to test your domain at different layers with different test frameworks, in order to ease the development process and transform your codebase in a stronghold.
This document provides an introduction to dependency injection containers (DIC). It begins by explaining dependency injection and its benefits over direct instantiation, such as easier testing and replacing dependencies. It then introduces the concept of a dependency injection container, which manages object instantiation and wiring of dependencies. Using a container allows configuring services differently for production versus development and avoids deeply nested instantiation code. The document demonstrates implementing a simple DI container and using it to resolve object graphs in place of direct construction.
Le Lutin Malin doit décorer les locaux de la start-up du Père Noël et c'est plus compliqué que prévu puisqu'il est limité par le système dans lequel il se trouve. Grâce aux Process Behavior Charts on voit bien que si rien ne change il ne pourra pas réussir à placer toutes les boules de noël au dessus de la gouttière, même avec les meilleurs encouragements du Père Noël...
Comment migrer une application peu testée, développée avec des outils RAD, pour intégrer de nombreuses évolutions de règles métiers et par la même occasion la rendre plus compréhensible, en ayant une démarche orientée Domain Driven Design ? La réponse n’est pas si évidente.
On peut bien sûr opter pour une réécriture complète du système mais ce n’est pas sans problème. Comment continuer à délivrer des fonctionnalités ? Comment s’assurer que le nouveau système aura bien le même comportement que l’ancien ? Et surtout, combien de temps cela va t’il prendre ?
Une autre piste est de refactorer le code petit à petit, d’introduire les nouveaux concepts lorsqu’un besoin se fait sentir, sans avoir besoin de bloquer tout autre développement. C’est ce que nous avons choisi de faire pour migrer un backoffice construit autour du bundle Symfony EasyAdmin.
Dans ce retour d’expérience nous verrons comment nous avons commencé à mieux connaître les règles métiers en lisant le code et en animant des Event Storming. Nous parlerons de la manière dont nous avons réussi à créer un filet de sécurité avec des tests en nous laissant guider par le code coverage, ou encore de comment nous avons introduit graduellement les nouveaux concepts métiers à l’aide des interfaces avant de modifier la base de données. Tout au long de la conférence nous présenterons les difficultés rencontrées et ce que nous avons mis en œuvre pour les déjouer.
As developers we sometimes add tools to the systems we are working on without thinking twice about the complexity they bring, because we pretend to be able to foresee what the future will be or just because we are following the hype. In this talk I share my view on this subject, why I think this is arming projects and explore a few alternatives to current buzzwords in order to gain simplicity.
Passer de 5 à 35 développeurs présente de nombreux challenges. Dans cette présentation se trouve une liste d'outils et de pratiques pour accompagner cette croissance.
Les exceptions, oui, mais pas n'importe commentCharles Desneuf
Les exceptions sont très pratiques pour communiquer que quelque chose s'est mal passé dans un système informatique, mais mal utilisées elles peuvent rendre un système difficile à utilisé et peu fiable.
What is the best way to deal with exceptions that are supposed to pop out from time to time because they are business related.
What is the appropriate log level ? What should we do if we sometimes want them to stop the process and in some other cases we don't ?
Most important New features of Oracle 23c for DBAs and Developers. You can get more idea from my youtube channel video from https://youtu.be/XvL5WtaC20A
Measures in SQL (SIGMOD 2024, Santiago, Chile)Julian Hyde
SQL has attained widespread adoption, but Business Intelligence tools still use their own higher level languages based upon a multidimensional paradigm. Composable calculations are what is missing from SQL, and we propose a new kind of column, called a measure, that attaches a calculation to a table. Like regular tables, tables with measures are composable and closed when used in queries.
SQL-with-measures has the power, conciseness and reusability of multidimensional languages but retains SQL semantics. Measure invocations can be expanded in place to simple, clear SQL.
To define the evaluation semantics for measures, we introduce context-sensitive expressions (a way to evaluate multidimensional expressions that is consistent with existing SQL semantics), a concept called evaluation context, and several operations for setting and modifying the evaluation context.
A talk at SIGMOD, June 9–15, 2024, Santiago, Chile
Authors: Julian Hyde (Google) and John Fremlin (Google)
https://doi.org/10.1145/3626246.3653374
What to do when you have a perfect model for your software but you are constrained by an imperfect business model?
This talk explores the challenges of bringing modelling rigour to the business and strategy levels, and talking to your non-technical counterparts in the process.
How Can Hiring A Mobile App Development Company Help Your Business Grow?ToXSL Technologies
ToXSL Technologies is an award-winning Mobile App Development Company in Dubai that helps businesses reshape their digital possibilities with custom app services. As a top app development company in Dubai, we offer highly engaging iOS & Android app solutions. https://rb.gy/necdnt
Mobile app Development Services | Drona InfotechDrona Infotech
Drona Infotech is one of the Best Mobile App Development Company In Noida Maintenance and ongoing support. mobile app development Services can help you maintain and support your app after it has been launched. This includes fixing bugs, adding new features, and keeping your app up-to-date with the latest
Visit Us For :
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsPeter Muessig
The UI5 tooling is the development and build tooling of UI5. It is built in a modular and extensible way so that it can be easily extended by your needs. This session will showcase various tooling extensions which can boost your development experience by far so that you can really work offline, transpile your code in your project to use even newer versions of EcmaScript (than 2022 which is supported right now by the UI5 tooling), consume any npm package of your choice in your project, using different kind of proxies, and even stitching UI5 projects during development together to mimic your target environment.
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemPeter Muessig
Learn about the latest innovations in and around OpenUI5/SAPUI5: UI5 Tooling, UI5 linter, UI5 Web Components, Web Components Integration, UI5 2.x, UI5 GenAI.
Recording:
https://www.youtube.com/live/MSdGLG2zLy8?si=INxBHTqkwHhxV5Ta&t=0
Top 9 Trends in Cybersecurity for 2024.pptxdevvsandy
Security and risk management (SRM) leaders face disruptions on technological, organizational, and human fronts. Preparation and pragmatic execution are key for dealing with these disruptions and providing the right cybersecurity program.
Malibou Pitch Deck For Its €3M Seed Roundsjcobrien
French start-up Malibou raised a €3 million Seed Round to develop its payroll and human resources
management platform for VSEs and SMEs. The financing round was led by investors Breega, Y Combinator, and FCVC.
Microservice Teams - How the cloud changes the way we workSven Peters
A lot of technical challenges and complexity come with building a cloud-native and distributed architecture. The way we develop backend software has fundamentally changed in the last ten years. Managing a microservices architecture demands a lot of us to ensure observability and operational resiliency. But did you also change the way you run your development teams?
Sven will talk about Atlassian’s journey from a monolith to a multi-tenanted architecture and how it affected the way the engineering teams work. You will learn how we shifted to service ownership, moved to more autonomous teams (and its challenges), and established platform and enablement teams.
SOCRadar's Aviation Industry Q1 Incident Report is out now!
The aviation industry has always been a prime target for cybercriminals due to its critical infrastructure and high stakes. In the first quarter of 2024, the sector faced an alarming surge in cybersecurity threats, revealing its vulnerabilities and the relentless sophistication of cyber attackers.
SOCRadar’s Aviation Industry, Quarterly Incident Report, provides an in-depth analysis of these threats, detected and examined through our extensive monitoring of hacker forums, Telegram channels, and dark web platforms.
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesQuickdice ERP
Explore the seamless transition to e-invoicing with this comprehensive guide tailored for Saudi Arabian businesses. Navigate the process effortlessly with step-by-step instructions designed to streamline implementation and enhance efficiency.
Using Query Store in Azure PostgreSQL to Understand Query PerformanceGrant Fritchey
Microsoft has added an excellent new extension in PostgreSQL on their Azure Platform. This session, presented at Posette 2024, covers what Query Store is and the types of information you can get out of it.
E-commerce Development Services- Hornet DynamicsHornet Dynamics
For any business hoping to succeed in the digital age, having a strong online presence is crucial. We offer Ecommerce Development Services that are customized according to your business requirements and client preferences, enabling you to create a dynamic, safe, and user-friendly online store.
4. Découvrir des bugs
Permettre de réfactorer
Documenter
Réfléchir à l’interface du système
Détecter des problèmes de design
Photo by Brooke Lark on Unsplash
5. Découvrir des bugs
Permettre de réfactorer
Documenter
Réfléchir à l’interface du système
Détecter des problèmes de design
Photo by Brooke Lark on Unsplash
6. Découvrir des bugs
Permettre de réfactorer
Documenter
Réfléchir à l’interface du système
Détecter des problèmes de design
Photo by Brooke Lark on Unsplash
7. Découvrir des bugs
Permettre de réfactorer
Documenter
Réfléchir à l’interface du système
Détecter des problèmes de design
Photo by Brooke Lark on Unsplash
8. Découvrir des bugs
Permettre de réfactorer
Documenter
Réfléchir à l’interface du système
Détecter des problèmes de design
Photo by Brooke Lark on Unsplash
9. Indépendants de l’implémentation
Décrire le comportement du système
Avoir un résultat prédictible
Rapides
Indépendants les uns des autres
Simple à mettre en place
Photo by Brooke Lark on Unsplash
10. Indépendants de l’implémentation
Décrire le comportement du système
Avoir un résultat prédictible
Rapides
Indépendants les uns des autres
Simple à mettre en place
Photo by Brooke Lark on Unsplash
11. Indépendants de l’implémentation
Décrire le comportement du système
Avoir un résultat prédictible
Rapides
Indépendants les uns des autres
Simple à mettre en place
Photo by Brooke Lark on Unsplash
12. Indépendants de l’implémentation
Décrire le comportement du système
Avoir un résultat prédictible
Rapides
Indépendants les uns des autres
Simple à mettre en place
Photo by Brooke Lark on Unsplash
13. Indépendants de l’implémentation
Décrire le comportement du système
Avoir un résultat prédictible
Rapides
Indépendants les uns des autres
Simple à mettre en place
Photo by Brooke Lark on Unsplash
14. Indépendants de l’implémentation
Décrire le comportement du système
Avoir un résultat prédictible
Rapides
Indépendants les uns des autres
Simple à mettre en place
Photo by Brooke Lark on Unsplash
17. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
}
18. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
}
19. public function testIlAnnonceLePlatDuJour()
public function test_il_annonce_le_plat_du_jour()
/**
* @test
*/
public function il_annonce_le_plat_du_jour()
/**
* @test
*/
public function il annonce le plat du jour()
22. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
}
23. ➜ recettes phpunit --testdox tests/ServeurTest.php
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.
Serveur
[x] il annonce le plat du jour
[x] il transmet une commande pour le plat du jour a la cuisine
24. ➜ recettes phpunit --testdox tests/ServeurTest.php
PHPUnit 4.7.6 by Sebastian Bergmann and contributors.
Serveur
[x] il annonce le plat du jour
[x] il transmet une commande pour le plat du jour a la cuisine
25. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
}
26. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
}
28. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des
gencives de porc',
$annonce
);
}
}
29. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des
gencives de porc',
$annonce
);
}
}
Arrange
30. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des
gencives de porc',
$annonce
);
}
}
Act
31. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_il_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des
gencives de porc',
$annonce
);
}
}
Assert
33. public function test_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlat()
->willReturn('Gencives de porc !')
->shouldBeCalledTimes(1);
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
34. class Serveur {
public function annonceLeMenu() {
$plat = $this->cuisine->quelEstLePlatDuJour();
// fait autre chose, oublie le menu
$plat = $this->cuisine->quelEstLePlatDuJour();
return sprintf(
'Le chef vous propose aujourd'hui %s',
$this->transformeNomDuPlat($plat)
);
}
}
35. class Serveur {
public function annonceLeMenu() {
$plat = 'Gencives de porc !';
return sprintf(
'Le chef vous propose aujourd'hui %s',
$this->transformeNomDuPlat($plat)
);
}
}
36. public function test_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlat()
->willReturn('Gencives de porc !')
->shouldBeCalledTimes(1);
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
37. public function test_annonce_le_plat_du_jour()
{
$cuisine = $this->prophesize(Cuisine::class);
$cuisine
->quelEstLePlatDuJour()
->willReturn('Gencives de porc !');
$serveur = new Serveur($cuisine->reveal());
$annonce = $serveur->annonceLePlatDuJour();
$this->assertEquals(
'Le chef vous propose aujourd'hui des gencives de porc',
$annonce
);
}
38. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_transmet_une_commande_pour_le_plat_du_jour_a_la_cuisine()
{
$cuisine = $this->prophesize(Cuisine::class);
$serveur = new Serveur($cuisine->reveal());
$serveur->recoitUneCommandePourUnPlatDuJour();
$cuisine
->ilFautUnPlatDuJour()
->shouldHaveBeenCalledTimes(1);
}
}
39. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_transmet_une_commande_pour_le_plat_du_jour_a_la_cuisine()
{
$cuisine = $this->prophesize(Cuisine::class);
$serveur = new Serveur($cuisine->reveal());
$serveur->recoitUneCommandePourUnPlatDuJour();
$cuisine
->ilFautUnPlatDuJour()
->shouldHaveBeenCalledTimes(1);
}
}
Arrange
40. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_transmet_une_commande_pour_le_plat_du_jour_a_la_cuisine()
{
$cuisine = $this->prophesize(Cuisine::class);
$serveur = new Serveur($cuisine->reveal());
$serveur->recoitUneCommandePourUnPlatDuJour();
$cuisine
->ilFautUnPlatDuJour()
->shouldHaveBeenCalledTimes(1);
}
}
Act
41. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_transmet_une_commande_pour_le_plat_du_jour_a_la_cuisine()
{
$cuisine = $this->prophesize(Cuisine::class);
$serveur = new Serveur($cuisine->reveal());
$serveur->recoitUneCommandePourUnPlatDuJour();
$cuisine
->ilFautUnPlatDuJour()
->shouldHaveBeenCalledTimes(1);
}
}
Assert
42. class ServeurTest extends PHPUnit_Framework_TestCase {
public function test_transmet_une_commande_pour_le_plat_du_jour_a_la_cuisine()
{
$cuisine = $this->prophesize(Cuisine::class);
$serveur = new Serveur($cuisine->reveal());
$serveur->recoitUneCommandePourUnPlatDuJour();
$cuisine
->ilFautUnPlatDuJour()
->shouldHaveBeenCalledTimes(1);
}
}
50. class PizzaioloTest extends PHPUnit_Framework_TestCase {
public function test_prepare_une_pizza_margherita_maison()
{
$pizzaiolo = new Pizzaiolo();
$pizza = $pizzaiolo->preparePizzaMargheritaMaison();
$this->assertEquals(
['pate', 'sauce tomate', 'basilic', 'mozzarella'],
$pizza->ingredients()
);
}
}
51. class PizzaSurgelee {
public function __construct($ingredients)
{
$this->ingredients = $ingredients;
}
public function ingredients()
{
return $this->ingredients;
}
}
52. class Pizzaiolo {
public function preparePizzaMargheritaMaison(){
$pizzaSurgelee = $this->acheteUnePizzaMargheritaSurgelee();
return $this->rechauffeLaPizza($pizzaSurgelee);
}
}
56. class Pizzaiolo {
public function preparePizzaMargheritaMaison() {
$pateAPizza = new PateAPizza();
$this->etaleLaPate($pateAPizza);
$this->enduitDeSauceTomate($pateAPizza);
$this->disposeLaMozzarella($pateAPizza);
$this->placeLeBasilic($pateAPizza);
return $this->cuire($pateAPizza);
}
}
58. class PizzaMaison {
public function __construct($ingredients)
{
$this->ingredients = $ingredients;
}
public function ingredients()
{
return $this->ingredients;
}
}
59. class PizzaMaison {
public function __construct($ingredients)
{
$this->ingredients = $ingredients;
}
public function ingredients()
{
return $this->ingredients;
}
}
61. class EndiveTest extends PHPUnit_Framework_TestCase {
public function test_une_endive_de_base_est_crue() {
$endive = new Endive();
$this->assertTrue($endive->crue());
}
public function test_une_endive_de_base_est_bonne() {
$endive = new Endive();
$this->assertTrue($endive->bonne());
}
public function test_une_endive_cuite_nest_pas_crue() {
$endive = new Endive();
$endive->cuire();
$this->assertFalse($endive->crue());
}
public function test_une_endive_cuite_nest_pas_bonne() {
$endive = new Endive();
$endive->cuire();
$this->assertFalse($endive->bonne());
}
}
62. public function test_une_endive_de_base_est_crue() {
$endive = new Endive();
$this->assertTrue($endive->crue());
}
public function test_une_endive_de_base_est_bonne() {
$endive = new Endive();
$this->assertTrue($endive->bonne());
}
63. public function test_une_endive_cuite_nest_pas_crue(){
$endive = new Endive();
$endive->cuire();
$this->assertFalse($endive->crue());
}
public function test_une_endive_cuite_nest_pas_bonne() {
$endive = new Endive();
$endive->cuire();
$this->assertFalse($endive->bonne());
}
64. class UneEndiveDeBaseTest extends PHPUnit_Framework_TestCase {
public function setUp()
{
$this->endive = new Endive();
}
public function test_est_crue()
{
$this->assertTrue($this->endive->crue());
}
public function test_est_bonne()
{
$this->assertTrue($this->endive->bonne());
}
}
65. class UneEndiveCuiteTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->endive = new Endive();
$this->endive->cuire();
}
public function test_nest_pas_crue()
{
$this->assertFalse($this->endive->crue());
}
public function test_nest_pas_bonne()
{
$this->assertFalse($this->endive->bonne());
}
}
66. class UneEndiveDeBaseTest extends PHPUnit_Framework_TestCase {
public function setUp()
{
$this->endive = new Endive();
}
public function test_est_crue()
{
$this->assertTrue($this->endive->crue());
}
public function test_est_bonne()
{
$this->assertTrue($this->endive->bonne());
}
}
67. class UneEndiveCuiteTest extends PHPUnit_Framework_TestCase {
public function setUp()
{
$this->endive = new Endive();
$this->endive->cuire();
}
public function test_nest_pas_crue()
{
$this->assertFalse($this->endive->crue());
}
public function test_nest_pas_bonne()
{
$this->assertFalse($this->endive->bonne());
}
}
68. class UneEndiveDeBaseTest extends PHPUnit_Framework_TestCase {
public function setUp()
{
$this->endive = new Endive();
}
public function test_est_crue()
{
$this->assertTrue($this->endive->crue());
}
public function test_est_bonne()
{
$this->assertTrue($this->endive->bonne());
}
}
69. // UneEndiveDeBaseTest.php
public function setUp()
{
$this->endive = new Endive();
}
// UneEndiveCuiteTest.php
public function setUp()
{
$this->endive = new Endive();
$this->endive->cuire();
}
79. class Realistisk {
public function laga($tallrik, $varaktighet) {
sleep($duree);
return $this->fårEnKallTallrik(get_class($tallrik), $varaktighet);
}
}
85. public function test_cuit_au_four_donne_un_gratin_croustillant()
{
$gratin = new Gratin();
$four = $this->prophesize(Four::class);
$four->cuire($gratin, self::50_MINUTES)
->willReturn(new GratinCroustillant());
$plat = $gratin->cuireAvec($four->reveal());
$this->assertEquals(new GratinCroustillant(), $plat);
}
86. public function test_cuit_au_four_donne_un_gratin_croustillant()
{
$gratin = new Gratin();
$four = $this->prophesize(Four::class);
$four->cuire($gratin, self::50_MINUTES)
->willReturn(new GratinCroustillant());
$plat = $gratin->cuireAvec($four->reveal());
$this->assertEquals(new GratinCroustillant(), $plat);
}
87. class LeFourDeLaCuisine implements Four {
public function __construct(Realistisk $realistisk)
{
$this->realistisk = $realistisk;
}
public function cuire($plat, $duree)
{
$tallrik = $this->realistisk->laga($plat, $duree);
return $tallrik->fåTallrik();
}
}
88. class Gratin {
public function cuireAvec(Realistisk $realistisk, $duree) {
$tallrik = $realistisk->laga($this, $duree);
return $tallrik->fåTallrik();
}
}
89. class Gratin {
public function cuireAvec(Four $four, $duree) {
return $four->cuire($this, $duree);
}
}
90. class LeFourDeLaCuisineTest extends PHPUnit_Framework_TestCase {
public function test_cuit_un_fromage_de_chevre_en_chevre_chaud() {
$four = new FourDeLaCuisine(new Realistisk());
$plat = $four->cuire(new FromageDeChevre(), self::10_MINUTES);
$this->assertEquals(new ChevreChaud(), $plat);
}
}
91. class LeFourDeLaCuisineTest extends PHPUnit_Framework_TestCase {
public function test_cuit_un_fromage_de_chevre_en_chevre_chaud() {
$four = new FourDeLaCuisine(new Realistisk());
$plat = $four->cuire(new FromageDeChevre(), self::10_MINUTES);
$this->assertEquals(new ChevreChaud(), $plat);
}
}
94. class Quiche {
public function __construct(Datetime $dateCuisson) {
$this->dateCuisson = $dateCuisson;
}
public function peutEtreConsommee()
{
return $this->dateCuisson->modify('+2 day') < new Datetime();
}
}
98. class Quiche {
public function __construct(Datetime $cuisineeLe) {
$this->cuisineeLe = $cuisineeLe;
}
public function peutEtreConsommee(Horloge $horloge)
{
return $this->cuisineeLe->modify('+2 day') < $horloge->maintenant();
}
}
105. class PlatDePatesTest extends PHPUnit_Framework_TestCase {
public function test_est_bon_sil_contient_de_la_viande_du_fromage_et_de_la_sauce()
{
$platDePates = new PlatDePates([
new Ingredient('fromage', 'parmesan'),
new Ingredient('viande', 'lardons'),
new Ingredient('sauce', 'creme fraiche'),
new Ingredient('legume', 'oignon'),
]);
$this->assertTrue($platDePates->estBon());
}
}
106. class Ingredient {
public function __construct($type, $nom)
{
$this->type = $type;
$this->nom = $nom;
}
}
107. class Ingredient {
public function __construct($type, $nom, $DLC)
{
$this->type = $type;
$this->nom = $nom;
$this->DLC = $DLC;
}
}
109. class IngredientMother {
public static function viande()
{
return new Ingredient('viande', 'boeuf hache', new Datetime());
}
public static function legume()
{
return new Ingredient('legume', 'salsifi', new Datetime());
}
public static function fromage()
{
return new Ingredient('fromage', 'coulommier', new Datetime());
}
public static function sauce()
{
return new Ingredient('sauce', 'soja', new Datetime());
}
}
115. class PlatDePatesTest extends PHPUnit_Framework_TestCase {
public function test_nest_pas_consommable_sil_contient_un_ingredient_avec_une_DLC_depassee()
{
$platDePates = new PlatDePates([
new Ingredient('parmesan', new DateTime('2017-10-30')),
new Ingredient('lardons', new DateTime('2017-10-15')),
]);
$this->assertFalse(
$platDePates->estConsommableLe(new DateTime('2017-10-20'))
);
}
}
116. class PlatDePatesTest extends PHPUnit_Framework_TestCase {
public function test_nest_pas_consommable_sil_contient_un_ingredient_avec_une_DLC_depassee()
{
$platDePates = new PlatDePates([
new Ingredient('parmesan', new DateTime('2017-10-30')),
new Ingredient('lardons', new DateTime('2017-10-15')),
]);
$this->assertFalse(
$platDePates->estConsommableLe(new DateTime('2017-10-20'))
);
}
}
117. class IngredientBuilder {
private $nom;
private $dlc;
public function __construct() {
$this->nom = "pomme de terre";
$this->dlc = new Datetime();
}
public function nomme($nom)
{
$this->nom = $nom;
return $this;
}
public function avecUneDLCLe($dlc)
{
$this->dlc = $dlc;
return $this;
}
public function build()
{
return new Ingredient($this->nom, $this->dlc);
}
}
119. class IngredientBuilder {
public function nomme($nom)
{
$this->nom = $nom;
return $this;
}
public function avecUneDLCLe($dlc)
{
$this->dlc = $dlc;
return $this;
}
}
120. class IngredientBuilder {
public function nomme($nom)
{
$this->nom = $nom;
return $this;
}
public function avecUneDLCLe($dlc)
{
$this->dlc = $dlc;
return $this;
}
}
126. class PlatTest extends PHPUnit_Framework_TestCase {
public function test_est_vegetarien_sil_ne_contient_que_de_la_salade(){
$plat = new Plat(['salade']);
$this->assertTrue($plat->estVegetarien());
}
public function test_est_vegetarien_sil_ne_contient_que_du_fromage()
{
$plat = new Plat(['fromage']);
$this->assertTrue($plat->estVegetarien());
}
public function test_nest_pas_vegetarien_sil_contient_de_la_viande()
{
$plat = new Plat(['salade', 'viande']);
$this->assertFalse($plat->estVegetarien());
}
}
127. class PlatTest extends PHPUnit_Framework_TestCase {
public function test_est_vegetarien_sil_ne_contient_que_de_la_salade(){
$plat = new Plat(['salade']);
$this->assertTrue($plat->estVegetarien());
}
public function test_est_vegetarien_sil_ne_contient_que_du_fromage()
{
$plat = new Plat(['fromage']);
$this->assertTrue($plat->estVegetarien());
}
public function test_nest_pas_vegetarien_sil_contient_de_la_viande()
{
$plat = new Plat(['salade', 'viande']);
$this->assertFalse($plat->estVegetarien());
}
}
128. class PlatTest extends PHPUnit_Framework_TestCase {
public function test_est_vegetarien_sil_ne_contient_que_de_la_salade(){
$plat = new Plat(['salade']);
$this->assertTrue($plat->estVegetarien());
}
public function test_est_vegetarien_sil_ne_contient_que_du_fromage()
{
$plat = new Plat(['fromage']);
$this->assertTrue($plat->estVegetarien());
}
public function test_nest_pas_vegetarien_sil_contient_de_la_viande()
{
$plat = new Plat(['salade', 'viande']);
$this->assertFalse($plat->estVegetarien());
}
}
129. class PlatTest extends PHPUnit_Framework_TestCase {
public function test_est_vegetarien_sil_ne_contient_que_de_la_salade(){
$plat = new Plat(['salade']);
$this->assertTrue($plat->estVegetarien());
}
public function test_est_vegetarien_sil_ne_contient_que_du_fromage()
{
$plat = new Plat(['fromage']);
$this->assertTrue($plat->estVegetarien());
}
public function test_nest_pas_vegetarien_sil_contient_de_la_viande()
{
$plat = new Plat(['salade', 'viande']);
$this->assertFalse($plat->estVegetarien());
}
}
131. public function plats()
{
return [
'Un plat qui ne contient que la salade est vegetarien' => [
new Plat(['salade']), self::EST_VEGETARIEN
],
'Un plat avec du fromage est vegetarien' => [
new Plat(['fromage']), self::EST_VEGETARIEN
],
'Un plat avec de la viande n'est pas vegetarien' => [
new Plat(['viande']), self::NEST_PAS_VEGETARIEN
],
];
}
132. public function plats()
{
return [
'Un plat qui ne contient que la salade est vegetarien' => [
new Plat(['salade']), self::EST_VEGETARIEN
],
'Un plat avec du fromage est vegetarien' => [
new Plat(['fromage']), self::EST_VEGETARIEN
],
'Un plat avec de la viande n'est pas vegetarien' => [
new Plat(['viande']), self::NEST_PAS_VEGETARIEN
],
];
}
133. public function plats()
{
return [
'Un plat qui ne contient que la salade est vegetarien' => [
new Plat(['salade']), self::EST_VEGETARIEN
],
'Un plat avec du fromage est vegetarien' => [
new Plat(['fromage']), self::EST_VEGETARIEN
],
'Un plat avec de la viande n'est pas vegetarien' => [
new Plat(['viande']), self::NEST_PAS_VEGETARIEN
],
];
}
134. public function plats()
{
return [
'Un plat qui ne contient que la salade est vegetarien' => [
new Plat(['salade']), self::EST_VEGETARIEN
],
'Un plat avec du fromage est vegetarien' => [
new Plat(['fromage']), self::EST_VEGETARIEN
],
'Un plat avec de la viande n'est pas vegetarien' => [
new Plat(['viande']), self::NEST_PAS_VEGETARIEN
],
];
}
135. /**
* @dataProvider plats
*/
public function test_est_vegetarien_sil_ne_contient_que_des_ingredients_vegetariens
($plat, $estVegetarien)
{
$this->assertEquals($estVegetarien, $plat->estVegetarien());
}
136. class PlatTest extends PHPUnit_Framework_TestCase {
public function test_est_vegetarien_sil_ne_contient_que_de_la_salade(){
$plat = new Plat(['salade']);
$this->assertTrue($plat->estVegetarien());
}
public function test_est_vegetarien_sil_ne_contient_que_du_fromage()
{
$plat = new Plat(['fromage']);
$this->assertTrue($plat->estVegetarien());
}
public function test_nest_pas_vegetarien_sil_contient_de_la_viande()
{
$plat = new Plat(['salade', 'viande']);
$this->assertFalse($plat->estVegetarien());
}
}
137. class PlatTest extends PHPUnit_Framework_TestCase {
const EST_VEGETARIEN = true;
const NEST_PAS_VEGETARIEN = false;
/**
* @dataProvider plats
*/
public function test_est_vegetarien_sil_ne_contient_que_des_ingredients_vegetariens
($plat, $estVegetarien)
{
$this->assertEquals($estVegetarien, $plat->estVegetarien());
}
public function plats()
{
return [
'Un plat qui ne contient que la salade est vegetarien' => [
new Plat(['salade']), self::EST_VEGETARIEN
],
'Un plat avec du fromage est vegetarien' => [
new Plat(['fromage']), self::EST_VEGETARIEN
],
'Un plat avec de la viande n'est pas vegetarien' => [
new Plat(['viande']), self::NEST_PAS_VEGETARIEN
],
];
}
}
138. Assurez vous que vous
testez ce que vous
voulez tester.
Photo by rawpixel.com on Unsplash