summaryrefslogtreecommitdiffstats
path: root/5.patch
blob: e430650aee22c7700ba1907f2a116e200e66f608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
From 2d3eaa98c1022df06bf667b0284316d73b5e6f00 Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Tue, 7 Nov 2017 09:02:35 +0100
Subject: [PATCH 2/2] add 3 real tests

---
 tests/cache.phpt | 23 +++++++++++++++++++++++
 tests/file.phpt  | 23 +++++++++++++++++++++++
 tests/shm.phpt   | 23 +++++++++++++++++++++++
 3 files changed, 69 insertions(+)
 create mode 100644 tests/cache.phpt
 create mode 100644 tests/file.phpt
 create mode 100644 tests/shm.phpt

diff --git a/tests/cache.phpt b/tests/cache.phpt
new file mode 100644
index 0000000..d6c5157
--- /dev/null
+++ b/tests/cache.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DB access using cache method
+--SKIPIF--
+<?php
+if(!extension_loaded('ip2location')) die('skip missing extension');
+?>
+--FILE--
+<?php
+/*Test DB access using file mathod*/ 
+var_dump(ip2location_open(__DIR__ . '/IP-COUNTRY-SAMPLE.BIN'));
+var_dump(ip2location_open_mem(IP2LOCATION_CACHE_MEMORY));
+var_dump(ip2location_get_country_short('25.5.10.2'));
+var_dump(ip2location_get_country_long('25.5.10.2'));
+var_dump(ip2location_close());
+?>
+Done
+--EXPECTF--
+bool(true)
+bool(true)
+string(2) "UK"
+string(14) "UNITED KINGDOM"
+NULL
+Done
diff --git a/tests/file.phpt b/tests/file.phpt
new file mode 100644
index 0000000..6b6bc4c
--- /dev/null
+++ b/tests/file.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DB access using file method
+--SKIPIF--
+<?php
+if(!extension_loaded('ip2location')) die('skip missing extension');
+?>
+--FILE--
+<?php
+/*Test DB access using file mathod*/ 
+var_dump(ip2location_open(__DIR__ . '/IP-COUNTRY-SAMPLE.BIN'));
+var_dump(ip2location_open_mem(IP2LOCATION_FILE_IO));
+var_dump(ip2location_get_country_short('25.5.10.2'));
+var_dump(ip2location_get_country_long('25.5.10.2'));
+var_dump(ip2location_close());
+?>
+Done
+--EXPECTF--
+bool(true)
+bool(true)
+string(2) "UK"
+string(14) "UNITED KINGDOM"
+NULL
+Done
diff --git a/tests/shm.phpt b/tests/shm.phpt
new file mode 100644
index 0000000..056c1d4
--- /dev/null
+++ b/tests/shm.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DB access using shared memory method
+--SKIPIF--
+<?php
+if(!extension_loaded('ip2location')) die('skip missing extension');
+?>
+--FILE--
+<?php
+/*Test DB access using file mathod*/ 
+var_dump(ip2location_open(__DIR__ . '/IP-COUNTRY-SAMPLE.BIN'));
+var_dump(ip2location_open_mem(IP2LOCATION_SHARED_MEMORY));
+var_dump(ip2location_get_country_short('25.5.10.2'));
+var_dump(ip2location_get_country_long('25.5.10.2'));
+var_dump(ip2location_close());
+?>
+Done
+--EXPECTF--
+bool(true)
+bool(true)
+string(2) "UK"
+string(14) "UNITED KINGDOM"
+NULL
+Done