나는 응용 프로그램 테스트와 Symfony2에서 새로운 것이므로 한 가지 질문이 있습니다. exaple 들어, 몇 가지 sevices, 하나의 메일을 보내 ($this->mailer->send($message)
) 그리고 두 번째 엔티티 인스턴스와 몇 가지 일을하고 인스턴스 prepeared 영속, 그래서 첫 번째 경우에만 assertTrue()
(sended 또는하지 않음) 확인해야합니까? 하지만 두 번째를 확인해야 할 필요가 있습니까? 누군가 나를 도울 수 있습니까?Unit Testing services in Symfony2
0
A
답변
0
실제로 이것은 매우 광범위한 질문입니다. 엔티티를 "수정하는"서비스를 테스트 할 때 일반적으로 수행하는 한 가지 예는 다음과 같습니다.
서비스 Adder
엔티티의 상태를 업데이트합니다. 다른 엔티티에 기반하여 엔티티에 값을 추가하고 지속되기 전에 올바른 값을 설정합니다. 물론
// src/Acme/DemoBundle/Tests/Service/AdderTest.php
namespace Acme\DemoBundle\Tests\Service;
use Acme\DemoBundle\Service\Adder;
use Acme\DemoBundle\Entity\One;
use Acme\DemoBundle\Entity\Two;
class AdderTest extends \PHPUnit_Framework_TestCase
{
public function testAdd()
{
$add = new Adder();
$ent1 = new One();
$ent2 = new Two();
$ent2->setValue(1);
$add->setOne($ent1);
$add->setTwo($ent2);
$add->updateEntity();// $ent1->setValue($ent2->getValue()+1);
$this->assertEquals(2, $ent1->getValue());// Expected state of $ent1
}
}
, 그것은 일반적으로 더 복잡하지만 적어도 그것은 당신에게 시작하는 방법에 대한 아이디어 (엔티티의 상태를 업데이트하고 기업의 새로운 상태가 있는지 확인하기 위해 서비스를 사용을 줄 수 얻는다 하나 예상).
희망이 있습니다.
관련 문제
- 1. Grails Unit Testing Services - 어떻게 플러시합니까?
- 2. Services in Symfony2
- 3. Angular2 FormBuilder unit testing
- 4. Grails Unit Testing
- 5. Laravel - unit testing
- 6. ResourceManager 및 Unit Testing
- 7. Guice-servlet unit testing
- 8. Android gps unit testing
- 9. Python - unit testing
- 10. WorkFlow Unit Testing
- 11. unit testing system.timers.timer
- 12. Unit Testing MyBatis Handler
- 13. ObjectValidator unit testing
- 14. Trouble unit testing ReactiveCommand CanExecute
- 15. Unit testing REST API in laravel : 기본 인증이 무시되었습니다.
- 16. Unit Testing AngularJS 모듈 컨트롤러
- 17. Node.js unit testing (2013 년)
- 18. asp.net mvc nhibernate unit testing
- 19. Unit testing newbie help please
- 20. LiftWeb RESTHelper RestContinuction unit testing
- 21. Seam Component.getInstance() 및 unit testing
- 22. WPF unit testing, UIElement.RaiseEvent, ArgumentException
- 23. Unit-Testing PersistenceLayer (JPA/EclipseLink)
- 24. C# Windows Form Unit Testing
- 25. Laravel unit testing complete error
- 26. Unit Testing, Thread.CurrentPrincipal 및 IsAuthenticated 설정하는 방법
- 27. C# unit testing visual studio 2010
- 28. Python Unit Testing 테스트가 잘못된 입력을 조롱합니다.
- 29. Unit testing classes - 질문에 오류가 있습니까?
- 30. Visual Studio Unit Testing Framework 자습서?
@JakubZalas, assertTrue와 같은 간단한 테스트. – nowiko
@JakubZalas, 나는 얻을 수 없다. mailer 서비스가있다. 메일러 심포니 2 서비스에 의존한다. my_mailer servcice를 어떻게 인스턴스화 할 수 있습니까? – nowiko