|
4 | 4 |
|
5 | 5 | use BaseTestCase; |
6 | 6 | use Grimzy\LaravelMysqlSpatial\Eloquent\Builder; |
| 7 | +use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialExpression; |
7 | 8 | use Grimzy\LaravelMysqlSpatial\Eloquent\SpatialTrait; |
8 | 9 | use Grimzy\LaravelMysqlSpatial\MysqlConnection; |
9 | 10 | use Grimzy\LaravelMysqlSpatial\Types\LineString; |
@@ -36,50 +37,39 @@ protected function setUp() |
36 | 37 |
|
37 | 38 | public function testUpdatePoint() |
38 | 39 | { |
39 | | - $this->queryBuilder |
40 | | - ->shouldReceive('raw') |
41 | | - ->with("ST_GeomFromText('POINT(2 1)')") |
42 | | - ->once(); |
43 | | - |
| 40 | + $point = new Point(1, 2); |
44 | 41 | $this->queryBuilder |
45 | 42 | ->shouldReceive('update') |
| 43 | + ->with(['point' => new SpatialExpression($point)]) |
46 | 44 | ->once(); |
47 | 45 |
|
48 | | - $this->builder->update(['point' => new Point(1, 2)]); |
| 46 | + $this->builder->update(['point' => $point]); |
49 | 47 | } |
50 | 48 |
|
51 | 49 | public function testUpdateLinestring() |
52 | 50 | { |
53 | | - $this->queryBuilder |
54 | | - ->shouldReceive('raw') |
55 | | - ->with("ST_GeomFromText('LINESTRING(0 0,1 1,2 2)')") |
56 | | - ->once(); |
| 51 | + $linestring = new LineString([new Point(0, 0), new Point(1, 1), new Point(2, 2)]); |
57 | 52 |
|
58 | 53 | $this->queryBuilder |
59 | 54 | ->shouldReceive('update') |
| 55 | + ->with(['linestring' => new SpatialExpression($linestring)]) |
60 | 56 | ->once(); |
61 | 57 |
|
62 | | - $linestring = new LineString([new Point(0, 0), new Point(1, 1), new Point(2, 2)]); |
63 | | - |
64 | 58 | $this->builder->update(['linestring' => $linestring]); |
65 | 59 | } |
66 | 60 |
|
67 | 61 | public function testUpdatePolygon() |
68 | 62 | { |
69 | | - $this->queryBuilder |
70 | | - ->shouldReceive('raw') |
71 | | - ->with("ST_GeomFromText('POLYGON((0 0,1 0),(1 0,1 1),(1 1,0 0))')") |
72 | | - ->once(); |
73 | | - |
74 | | - $this->queryBuilder |
75 | | - ->shouldReceive('update') |
76 | | - ->once(); |
77 | | - |
78 | 63 | $linestrings[] = new LineString([new Point(0, 0), new Point(0, 1)]); |
79 | 64 | $linestrings[] = new LineString([new Point(0, 1), new Point(1, 1)]); |
80 | 65 | $linestrings[] = new LineString([new Point(1, 1), new Point(0, 0)]); |
81 | 66 | $polygon = new Polygon($linestrings); |
82 | 67 |
|
| 68 | + $this->queryBuilder |
| 69 | + ->shouldReceive('update') |
| 70 | + ->with(['polygon' => new SpatialExpression($polygon)]) |
| 71 | + ->once(); |
| 72 | + |
83 | 73 | $this->builder->update(['polygon' => $polygon]); |
84 | 74 | } |
85 | 75 | } |
|
0 commit comments