Changeset 10733
- Timestamp:
- 08/07/08 09:00:49 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
doc/branches/1.0/book/15-Unit-and-Functional-Testing.txt
r10189 r10733 187 187 $t->isa_ok('foobar', 'string', '\'foobar\' is a string'); 188 188 $t->isa_ok(new myObject(), 'myObject', 'new creates object of the right class'); 189 $t->can_ok(new myObject(), 'myMethod', 'objects of class myObject do have a myMethod method');189 $t->can_ok(new myObject(), 'myMethod', 'objects of class myObject do have a myMethod method'); 190 190 $array1 = array(1, 2, array(1 => 'foo', 'a' => '4')); 191 191 $t->is_deeply($array1, array(1, 2, array(1 => 'foo', 'a' => '4')), … … 663 663 $b->test()->is($dom->getElementsByTagName('input')->item(1)->getAttribute('type'),'text'); 664 664 665 But parsing an HTML document with the PHP DOM methods is still not fast and easy enough. If you are familiar with the CSS selectors, you know that they are an eve rmore powerful way to retrieve elements from an HTML document. Symfony provides a tool class called `sfDomCssSelector` that expects a DOM document as construction parameter. It has a getTexts() method that returns an array of strings according to a CSS selector, and a getElements() method that returns an array of DOM elements. See an example in Listing 15-20.665 But parsing an HTML document with the PHP DOM methods is still not fast and easy enough. If you are familiar with the CSS selectors, you know that they are an even more powerful way to retrieve elements from an HTML document. Symfony provides a tool class called `sfDomCssSelector` that expects a DOM document as construction parameter. It has a getTexts() method that returns an array of strings according to a CSS selector, and a getElements() method that returns an array of DOM elements. See an example in Listing 15-20. 666 666 667 667 Listing 15-20 - The Test Browser Gives Access to the Response Content As an `sfDomCssSelector` Object … … 813 813 ok 2 - strtolower() transforms the input to lowercase 814 814 815 Functional tests should be grouped by page and start bya request. Listing 15-30 illustrates this practice.815 Functional tests should be grouped by page and start with a request. Listing 15-30 illustrates this practice. 816 816 817 817 Listing 15-30 - Example Functional Test Naming Practice doc/branches/1.1/book/15-Unit-and-Functional-Testing.txt
r10586 r10733 187 187 $t->isa_ok('foobar', 'string', '\'foobar\' is a string'); 188 188 $t->isa_ok(new myObject(), 'myObject', 'new creates object of the right class'); 189 $t->can_ok(new myObject(), 'myMethod', 'objects of class myObject do have a myMethod method');189 $t->can_ok(new myObject(), 'myMethod', 'objects of class myObject do have a myMethod method'); 190 190 $array1 = array(1, 2, array(1 => 'foo', 'a' => '4')); 191 191 $t->is_deeply($array1, array(1, 2, array(1 => 'foo', 'a' => '4')), … … 655 655 $b->test()->is($dom->getElementsByTagName('input')->item(1)->getAttribute('type'),'text'); 656 656 657 But parsing an HTML document with the PHP DOM methods is still not fast and easy enough. If you are familiar with the CSS selectors, you know that they are an eve rmore powerful way to retrieve elements from an HTML document. Symfony provides a tool class called `sfDomCssSelector` that expects a DOM document as construction parameter. It has a getTexts() method that returns an array of strings according to a CSS selector, and a getElements() method that returns an array of DOM elements. See an example in Listing 15-20.657 But parsing an HTML document with the PHP DOM methods is still not fast and easy enough. If you are familiar with the CSS selectors, you know that they are an even more powerful way to retrieve elements from an HTML document. Symfony provides a tool class called `sfDomCssSelector` that expects a DOM document as construction parameter. It has a getTexts() method that returns an array of strings according to a CSS selector, and a getElements() method that returns an array of DOM elements. See an example in Listing 15-20. 658 658 659 659 Listing 15-20 - The Test Browser Gives Access to the Response Content As an `sfDomCssSelector` Object … … 732 732 isRequestParameter('action', 'update')-> 733 733 734 throwsException()-> // Checks that the last request thr ownan exception734 throwsException()-> // Checks that the last request threw an exception 735 735 throwsException('RuntimeException')-> // Checks the class of the exception 736 736 throwsException(null, '/error/'); // Checks that the content of the exception message matches the regular expression … … 819 819 ok 2 - strtolower() transforms the input to lowercase 820 820 821 Functional tests should be grouped by page and start bya request. Listing 15-31 illustrates this practice.821 Functional tests should be grouped by page and start with a request. Listing 15-31 illustrates this practice. 822 822 823 823 Listing 15-31 - Example Functional Test Naming Practice doc/branches/1.2/book/15-Unit-and-Functional-Testing.txt
r10586 r10733 187 187 $t->isa_ok('foobar', 'string', '\'foobar\' is a string'); 188 188 $t->isa_ok(new myObject(), 'myObject', 'new creates object of the right class'); 189 $t->can_ok(new myObject(), 'myMethod', 'objects of class myObject do have a myMethod method');189 $t->can_ok(new myObject(), 'myMethod', 'objects of class myObject do have a myMethod method'); 190 190 $array1 = array(1, 2, array(1 => 'foo', 'a' => '4')); 191 191 $t->is_deeply($array1, array(1, 2, array(1 => 'foo', 'a' => '4')), … … 655 655 $b->test()->is($dom->getElementsByTagName('input')->item(1)->getAttribute('type'),'text'); 656 656 657 But parsing an HTML document with the PHP DOM methods is still not fast and easy enough. If you are familiar with the CSS selectors, you know that they are an eve rmore powerful way to retrieve elements from an HTML document. Symfony provides a tool class called `sfDomCssSelector` that expects a DOM document as construction parameter. It has a getTexts() method that returns an array of strings according to a CSS selector, and a getElements() method that returns an array of DOM elements. See an example in Listing 15-20.657 But parsing an HTML document with the PHP DOM methods is still not fast and easy enough. If you are familiar with the CSS selectors, you know that they are an even more powerful way to retrieve elements from an HTML document. Symfony provides a tool class called `sfDomCssSelector` that expects a DOM document as construction parameter. It has a getTexts() method that returns an array of strings according to a CSS selector, and a getElements() method that returns an array of DOM elements. See an example in Listing 15-20. 658 658 659 659 Listing 15-20 - The Test Browser Gives Access to the Response Content As an `sfDomCssSelector` Object … … 732 732 isRequestParameter('action', 'update')-> 733 733 734 throwsException()-> // Checks that the last request thr ownan exception734 throwsException()-> // Checks that the last request threw an exception 735 735 throwsException('RuntimeException')-> // Checks the class of the exception 736 736 throwsException(null, '/error/'); // Checks that the content of the exception message matches the regular expression … … 819 819 ok 2 - strtolower() transforms the input to lowercase 820 820 821 Functional tests should be grouped by page and start bya request. Listing 15-31 illustrates this practice.821 Functional tests should be grouped by page and start with a request. Listing 15-31 illustrates this practice. 822 822 823 823 Listing 15-31 - Example Functional Test Naming Practice