Skip to content

Commit d93248e

Browse files
committed
Still trying to get the tests working
1 parent 18e7a05 commit d93248e

5 files changed

Lines changed: 355 additions & 360 deletions

File tree

system/RESTful/ResourceController.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ public function initController(\CodeIgniter\HTTP\RequestInterface $request, \Cod
7575
parent::initController($request, $response, $logger);
7676

7777
// instantiate our model, if needed
78-
if (! empty($this->modelName))
78+
if (empty($this->model) && ! empty($this->modelName))
7979
{
8080
try
8181
{
82-
$this->model = $this->modelName();
82+
$this->model = new $this->modelName;
8383
}
8484
catch (\Exception $e)
8585
{
@@ -97,7 +97,7 @@ public function initController(\CodeIgniter\HTTP\RequestInterface $request, \Cod
9797
*/
9898
public function index()
9999
{
100-
return $this->fail('index: Action not implemented', 501);
100+
return $this->fail('Action not implemented', 501);
101101
}
102102

103103
/**
@@ -107,7 +107,7 @@ public function index()
107107
*/
108108
public function show($id = null)
109109
{
110-
$this->fail('Action not implemented', 501);
110+
return $this->fail('Action not implemented', 501);
111111
}
112112

113113
/**
@@ -117,7 +117,7 @@ public function show($id = null)
117117
*/
118118
public function new()
119119
{
120-
$this->fail('Action not implemented', 501);
120+
return $this->fail('Action not implemented', 501);
121121
}
122122

123123
/**
@@ -127,7 +127,7 @@ public function new()
127127
*/
128128
public function create()
129129
{
130-
$this->fail('Action not implemented', 501);
130+
return $this->fail('Action not implemented', 501);
131131
}
132132

133133
/**
@@ -137,7 +137,7 @@ public function create()
137137
*/
138138
public function edit($id = null)
139139
{
140-
$this->fail('Action not implemented', 501);
140+
return $this->fail('Action not implemented', 501);
141141
}
142142

143143
/**
@@ -147,7 +147,7 @@ public function edit($id = null)
147147
*/
148148
public function update($id = null)
149149
{
150-
$this->fail('Action not implemented', 501);
150+
return $this->fail('Action not implemented', 501);
151151
}
152152

153153
/**
@@ -157,7 +157,7 @@ public function update($id = null)
157157
*/
158158
public function delete($id = null)
159159
{
160-
$this->fail('Action not implemented', 501);
160+
return $this->fail('Action not implemented', 501);
161161
}
162162

163163
//--------------------------------------------------------------------
@@ -169,7 +169,17 @@ public function delete($id = null)
169169
*/
170170
public function setModel($which = null)
171171
{
172-
$this->model = $model;
172+
if (! empty($which))
173+
{
174+
if ($which instanceof \CodeIgniter\Model)
175+
{
176+
$this->model = $which;
177+
}
178+
else
179+
{
180+
$this->modelName = $which;
181+
}
182+
}
173183
}
174184

175185
/**

tests/_support/RESTful/Worker.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
*/
99
class Worker extends ResourceController
1010
{
11-
1211
}

0 commit comments

Comments
 (0)