Skip to content

Commit

Permalink
Fix locales tag inside replicator, bard, and grid
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Feb 21, 2024
1 parent 78d8f4b commit 50a0d9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Tags/Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private function getData()
return $this->data;
}

$id = $this->params->get('id', $this->context->value('id'));
$id = $this->params->get('id', $this->context->value('page.id'));

$data = Data::find($id);

Expand Down
20 changes: 10 additions & 10 deletions tests/Tags/LocalesTagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function it_loops_over_the_entry_for_each_site()

HTML;

$this->assertEquals($expected, $this->tag($this->template('{{ locales }}'), ['id' => '1']));
$this->assertEquals($expected, $this->tag($this->template('{{ locales }}'), ['page' => ['id' => '1']]));
}

/** @test */
Expand All @@ -161,7 +161,7 @@ public function it_skips_a_site_in_the_loop_if_the_entry_doesnt_exist()

$this->assertEquals(
'<hello><hola>',
$this->tag('{{ locales }}<{{ title }}>{{ /locales }}', ['id' => '1'])
$this->tag('{{ locales }}<{{ title }}>{{ /locales }}', ['page' => ['id' => '1']])
);
}

Expand Down Expand Up @@ -234,7 +234,7 @@ public function it_falls_back_to_the_sites_details_if_the_entry_doesnt_exist_and

HTML;

$this->assertEquals($expected, $this->tag($this->template('{{ locales all="true" }}'), ['id' => '1']));
$this->assertEquals($expected, $this->tag($this->template('{{ locales all="true" }}'), ['page' => ['id' => '1']]));
}

/** @test */
Expand Down Expand Up @@ -264,7 +264,7 @@ public function it_skips_a_site_in_the_loop_if_the_entry_is_a_draft()

$this->assertEquals(
'<hello><hola>',
$this->tag('{{ locales }}<{{ title }}>{{ /locales }}', ['id' => '1'])
$this->tag('{{ locales }}<{{ title }}>{{ /locales }}', ['page' => ['id' => '1']])
);
}

Expand Down Expand Up @@ -345,7 +345,7 @@ public function it_falls_back_to_the_sites_details_if_the_entry_is_a_draft_and_t

HTML;

$this->assertEquals($expected, $this->tag($this->template('{{ locales all="true" }}'), ['id' => '1']));
$this->assertEquals($expected, $this->tag($this->template('{{ locales all="true" }}'), ['page' => ['id' => '1']]));
}

/** @test */
Expand Down Expand Up @@ -374,7 +374,7 @@ public function it_skips_its_own_locale_when_self_param_is_false()

$this->assertEquals(
'<bonjour><hola>',
$this->tag('{{ locales self="false" }}<{{ title }}>{{ /locales }}', ['id' => '1'])
$this->tag('{{ locales self="false" }}<{{ title }}>{{ /locales }}', ['page' => ['id' => '1']])
);
}

Expand All @@ -397,7 +397,7 @@ public function it_shows_the_entry_in_a_given_site()

$this->assertEquals(
'<hola>',
$this->tag('{{ locales:espanol }}<{{ title }}>{{ /locales:espanol }}', ['id' => '1'])
$this->tag('{{ locales:espanol }}<{{ title }}>{{ /locales:espanol }}', ['page' => ['id' => '1']])
);
}

Expand All @@ -413,7 +413,7 @@ public function it_shows_nothing_if_the_entry_doesnt_exist_in_a_given_site()

$this->assertEquals(
'',
$this->tag('{{ locales:espanol }}<{{ title }}>{{ /locales:espanol }}', ['id' => '1'])
$this->tag('{{ locales:espanol }}<{{ title }}>{{ /locales:espanol }}', ['page' => ['id' => '1']])
);
}

Expand All @@ -429,7 +429,7 @@ public function it_displays_nothing_when_there_are_no_results()

$this->assertEquals(
'',
$this->tag('{{ locales self="false" }}you should not see this{{ /locales }}', ['id' => '1'])
$this->tag('{{ locales self="false" }}you should not see this{{ /locales }}', ['page' => ['id' => '1']])
);
}

Expand All @@ -446,7 +446,7 @@ public function it_displays_nothing_when_context_id_is_null()

$this->assertEquals(
'',
$this->tag('{{ locales }}you should not see this{{ /locales }}', ['id' => $value])
$this->tag('{{ locales }}you should not see this{{ /locales }}', ['page' => ['id' => $value]])
);
}
}

0 comments on commit 50a0d9d

Please sign in to comment.