| @@ 57-71 (lines=15) @@ | ||
| 54 | $this->mockButtonFragments($list, $group); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function testButtonPassesNoParentContextToSingletonWhenRelationListIsNotUsed() |
|
| 58 | { |
|
| 59 | $group = $this->objFromFixture(PeopleGroup::class, 'group'); |
|
| 60 | $this->mockSingleton(Person::class) |
|
| 61 | ->expects($this->once()) |
|
| 62 | ->method('canCreate') |
|
| 63 | ->with( |
|
| 64 | $this->anything(), |
|
| 65 | $this->callback(function ($arg) { |
|
| 66 | return !isset($arg['Parent']); |
|
| 67 | }) |
|
| 68 | ); |
|
| 69 | ||
| 70 | $this->mockButtonFragments(Person::get(), $group); |
|
| 71 | } |
|
| 72 | ||
| 73 | public function testButtonPassesNoParentContextToSingletonWhenNoParentRecordExists() |
|
| 74 | { |
|
| @@ 73-89 (lines=17) @@ | ||
| 70 | $this->mockButtonFragments(Person::get(), $group); |
|
| 71 | } |
|
| 72 | ||
| 73 | public function testButtonPassesNoParentContextToSingletonWhenNoParentRecordExists() |
|
| 74 | { |
|
| 75 | $group = $this->objFromFixture(PeopleGroup::class, 'group'); |
|
| 76 | $list = $group->People(); |
|
| 77 | ||
| 78 | $this->mockSingleton(Person::class) |
|
| 79 | ->expects($this->once()) |
|
| 80 | ->method('canCreate') |
|
| 81 | ->with( |
|
| 82 | $this->anything(), |
|
| 83 | $this->callback(function ($arg) { |
|
| 84 | return !isset($arg['Parent']); |
|
| 85 | }) |
|
| 86 | ); |
|
| 87 | ||
| 88 | $this->mockButtonFragments($list, null); |
|
| 89 | } |
|
| 90 | ||
| 91 | protected function mockButtonFragments(SS_List $list, $parent = null) |
|
| 92 | { |
|