瀏覽代碼

tests

tags/0.1.0
Robin Thoni 8 年之前
父節點
當前提交
bfbc301247
共有 2 個檔案被更改,包括 24 行新增9 行删除
  1. 9
    3
      test/TestBusiness.php
  2. 15
    6
      test/TestDataAccess.php

+ 9
- 3
test/TestBusiness.php 查看文件

10
 require_once("../vendor/autoload.php");
10
 require_once("../vendor/autoload.php");
11
 require_once("TestDataAccess.php");
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
     protected static function getDataAccess()
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 查看文件

7
  * Time: 5:21 PM
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
     public static function where($col, $operator, $value)
18
     public static function where($col, $operator, $value)
13
     {
19
     {
14
-        return new FakeModel();
20
+        return new Tests($value);
15
     }
21
     }
16
 
22
 
17
     public function first()
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
     public function toDbo()
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
     protected static function getModel()
37
     protected static function getModel()
29
     {
38
     {
30
-        return new FakeModel();
39
+        return new Tests();
31
     }
40
     }
32
 }
41
 }

Loading…
取消
儲存