|
5 | 5 | use Cake\ORM\TableRegistry; |
6 | 6 | use Cake\TestSuite\TestCase; |
7 | 7 | use Muffin\Obfuscate\Model\Behavior\Strategy\TinyStrategy; |
| 8 | +use Muffin\Obfuscate\Model\Behavior\Strategy\UuidStrategy; |
8 | 9 |
|
9 | 10 | class ObfuscateBehaviorTest extends TestCase |
10 | 11 | { |
@@ -33,15 +34,17 @@ public function setUp() |
33 | 34 | { |
34 | 35 | parent::setUp(); |
35 | 36 |
|
36 | | - $strategy = new TinyStrategy('5SX0TEjkR1mLOw8Gvq2VyJxIFhgCAYidrclDWaM3so9bfzZpuUenKtP74QNH6B'); |
37 | | - |
38 | 37 | $this->Authors = TableRegistry::get('Muffin/Obfuscate.Authors', ['table' => 'obfuscate_authors']); |
39 | | - $this->Authors->addBehavior('Muffin/Obfuscate.Obfuscate', compact('strategy')); |
| 38 | + $this->Authors->addBehavior('Muffin/Obfuscate.Obfuscate', [ |
| 39 | + 'strategy' => new UuidStrategy($this->Authors), |
| 40 | + ]); |
40 | 41 |
|
41 | 42 | $this->Comments = TableRegistry::get('Muffin/Obfuscate.Comments', ['table' => 'obfuscate_comments']); |
42 | 43 |
|
43 | 44 | $this->Tags = TableRegistry::get('Muffin/Obfuscate.Tags', ['table' => 'obfuscate_tags']); |
44 | | - $this->Tags->addBehavior('Muffin/Obfuscate.Obfuscate', compact('strategy')); |
| 45 | + $this->Tags->addBehavior('Muffin/Obfuscate.Obfuscate', [ |
| 46 | + 'strategy' => new TinyStrategy('5SX0TEjkR1mLOw8Gvq2VyJxIFhgCAYidrclDWaM3so9bfzZpuUenKtP74QNH6B'), |
| 47 | + ]); |
45 | 48 |
|
46 | 49 | $this->Articles = TableRegistry::get('Muffin/Obfuscate.Articles', ['table' => 'obfuscate_articles']); |
47 | 50 | $this->Articles->addBehavior('Muffin/Obfuscate.Obfuscate', ['strategy' => new TinyStrategy('5SX0TEjkR1mLOw8Gvq2VyJxIFhgCAYidrclDWaM3so9bfzZpuUenKtP74QNH6B')]); |
@@ -91,7 +94,7 @@ public function testFindObfuscate() |
91 | 94 | $this->Tags->getAlias(), |
92 | 95 | ])->first(); |
93 | 96 |
|
94 | | - $this->assertEquals('S', $result['author']['id']); |
| 97 | + $this->assertEquals('f1f88079-ec15-4863-ad41-7e85cfa98f3d', $result['author']['id']); |
95 | 98 | $this->assertEquals('S', $result['tags'][0]['id']); |
96 | 99 | $this->assertEquals(1, $result['comments'][0]['id']); |
97 | 100 | $this->assertEquals(2, $result['comments'][1]['id']); |
@@ -125,6 +128,11 @@ public function testFindObfuscated() |
125 | 128 | ->where(['id' => 'S']) |
126 | 129 | ->toArray(); |
127 | 130 | $this->assertEquals('1', $results[0]['id']); |
| 131 | + |
| 132 | + $results = $this->Authors->find('obfuscated') |
| 133 | + ->where(['id' => 'f1f88079-ec15-4863-ad41-7e85cfa98f3d']) |
| 134 | + ->toArray(); |
| 135 | + $this->assertEquals('1', $results[0]['id']); |
128 | 136 | } |
129 | 137 |
|
130 | 138 | /** |
|
0 commit comments