Skip to content
Newer
Older
100644 81 lines (67 sloc) 2.11 KB
0fe57ca @indiefan Added Base Integration test class and unit testing of said class.
indiefan authored Mar 9, 2010
1 <?php
2 /**
3 * Lithium: the most rad php framework
4 *
1d68573 @davidpersson Happy 2015.
davidpersson authored Jan 13, 2015
5 * @copyright Copyright 2015, Union of RAD (http://union-of-rad.org)
0fe57ca @indiefan Added Base Integration test class and unit testing of said class.
indiefan authored Mar 9, 2010
6 * @license http://opensource.org/licenses/bsd-license.php The BSD License
7 */
8
9 namespace lithium\test;
10
bfbee4a @jperras Adding class doc block for `test\Integration`.
jperras authored Jul 5, 2010
11 /**
12 * This is the base class for integration tests.
13 *
14 * Integration tests are for determining that different parts of the framework will work
15 * together (integrate) as expected. An example of a common integration test would be for
16 * ensuring that an adapter interacts correctly with the class it is designed to interface
17 * with. Example: the `Session` class and the `Php` adapter. Unit tests will ensure that
18 * both the `Session` and `Php` classes behave correctly under isolation, while an integration
19 * test ensures that the two classes interact and interface correctly.
20 */
0fe57ca @indiefan Added Base Integration test class and unit testing of said class.
indiefan authored Mar 9, 2010
21 class Integration extends \lithium\test\Unit {
22
23 /**
bfbee4a @jperras Adding class doc block for `test\Integration`.
jperras authored Jul 6, 2010
24 * Auto init for applying Integration filter to this test class.
0fe57ca @indiefan Added Base Integration test class and unit testing of said class.
indiefan authored Mar 9, 2010
25 *
26 * @return void
27 */
28 protected function _init() {
29 parent::_init();
30
31 $this->applyFilter('run', function($self, $params, $chain) {
32 $before = $self->results();
33
34 $chain->next($self, $params, $chain);
35
36 $after = $self->results();
37
38 while (count($after) > count($before)) {
39 $result = array_pop($after);
78504c4 @jails Fix typo according to li3_quality.
jails authored Jan 31, 2013
40 if ($result['result'] === 'fail') {
0fe57ca @indiefan Added Base Integration test class and unit testing of said class.
indiefan authored Mar 9, 2010
41 return false;
42 }
43 }
44 });
45 }
77af1d5 @blainesch Update unit tests to not use external resources.
blainesch authored Feb 28, 2013
46
47 /**
48 * Checks for a working internet connection.
49 *
50 * This method is used to check for a working connection to google.com, both
51 * testing for proper DNS resolution and reading the actual URL.
52 *
53 * @param array $config Override the default URL to check.
54 * @return boolean True if a network connection is established, false otherwise.
55 */
56 protected function _hasNetwork($config = array()) {
57 $defaults = array(
58 'scheme' => 'http',
59 'host' => 'google.com'
60 );
61 $config += $defaults;
62
63 $url = "{$config['scheme']}://{$config['host']}";
64 $failed = false;
65
66 set_error_handler(function($errno, $errstr) use (&$failed) {
67 $failed = true;
68 });
69
70 dns_check_record($config['host'], 'A');
71
72 if ($handle = fopen($url, 'r')) {
73 fclose($handle);
74 }
75
76 restore_error_handler();
77 return !$failed;
78 }
0fe57ca @indiefan Added Base Integration test class and unit testing of said class.
indiefan authored Mar 9, 2010
79 }
80
81 ?>
Something went wrong with that request. Please try again.