TAILIEUCHUNG - PHP in Action phần 6

Chúng tôi đã có một thử nghiệm lớp học có sản phẩm nào được gọi là TestOfMysqlTransaction. Mỗi thử nghiệm cá nhân sẽ được thực hiện như một phương pháp trong các lớp học thử nghiệm. Đây là lần đầu tiên thử nghiệm thực tế của chúng tôi: | This is all we need to create the template file. We take this output stick it in a file and call it something original like . What we are doing here is actually a form of Kent Beck s FakeIt pattern Beck . It s analogous to what we did in chapter 9 to make the TestOfMysqlTransaction pass. We make the code work by hard-coding the data that will make the tests pass then we can start inserting real data. As a first step toward real data we create a PHP section at the beginning set the desired data as variables and use the variables in the HTML section at the end of the template file. After we make our test reporter class generate the variables we can remove this PHP section. The template is shown in listing . Listing PHP template file created from the test output php testname SomeTest run 1 Number of cases actually run cases 1 Total number of cases passes 0 failures 2 exceptions 0 count 0 Start counting tests at 0 ok FALSE failreports array array message Equal expectation fails because Integer 1 . differs from Integer 2 by 1 at line 8 breadcrumb testSomething array message Equal expectation fails because Integer 2 . differs from Integer 3 by 1 at line 9 breadcrumb testSomething testname php foreach failreports as failure count failure message failure breadcrumb php endforeach php if ok OK php else FAILURES php endif Test cases run run cases Passes passes Failures failures Exceptions exceptions 250 CHAPTER 11 Refactoring web applications The template consists mostly of variables in addition it has the essential logic for generating the output A foreach loop to show the test failures A count variable to keep track of how many failures we ve displayed An if-else conditional to display a different message depending on whether some tests failed The first half of the file just sets the variables the second half is the actual template that outputs the results. The second half is what would normally be an HTML section although in this case there is no .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.