Browse Source

tests

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
bfbc301247
2 changed files with 24 additions and 9 deletions
  1. 9
    3
      test/TestBusiness.php
  2. 15
    6
      test/TestDataAccess.php

+ 9
- 3
test/TestBusiness.php View File

@@ -10,13 +10,19 @@
10 10
 require_once("../vendor/autoload.php");
11 11
 require_once("TestDataAccess.php");
12 12
 
13
+function abort($code, $reason)
14
+{
15
+    echo "ABORTED: $code, $reason\n";
16
+    exit;
17
+}
13 18
 
14
-class TestBusiness extends \Luticate\Utils\LuBusiness
19
+class TestsBusiness extends \Luticate\Utils\LuBusiness
15 20
 {
16 21
     protected static function getDataAccess()
17 22
     {
18
-        return new TestDataAccess();
23
+        return new TestsDataAccess();
19 24
     }
20 25
 }
21 26
 
22
-var_dump(TestBusiness::getById(42));
27
+var_dump(TestsBusiness::getById(42));
28
+var_dump(TestsBusiness::getById(4242));

+ 15
- 6
test/TestDataAccess.php View File

@@ -7,26 +7,35 @@
7 7
  * Time: 5:21 PM
8 8
  */
9 9
 
10
-class FakeModel
10
+class Tests
11 11
 {
12
+    private $value = null;
13
+    public function __construct($value = null)
14
+    {
15
+        $this->value = $value;
16
+    }
17
+
12 18
     public static function where($col, $operator, $value)
13 19
     {
14
-        return new FakeModel();
20
+        return new Tests($value);
15 21
     }
16 22
 
17 23
     public function first()
18 24
     {
19
-        return new FakeModel();
25
+        if ($this->value != 42) {
26
+            return null;
27
+        }
28
+        return new Tests($this->value);
20 29
     }
21 30
     public function toDbo()
22 31
     {
23
-        return new FakeModel();
32
+        return new Tests($this->value);
24 33
     }
25 34
 }
26 35
 
27
-class TestDataAccess extends \Luticate\Utils\LuDataAccess {
36
+class TestsDataAccess extends \Luticate\Utils\LuDataAccess {
28 37
     protected static function getModel()
29 38
     {
30
-        return new FakeModel();
39
+        return new Tests();
31 40
     }
32 41
 }

Loading…
Cancel
Save