Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Update BoardsTest.php #488

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "seregazhuk/pinterest-bot",
"name": "maparole/pinterest-bot",
"description": "PHP library for Pintrest",
"keywords": [
"php",
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Providers/BoardSections.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function update($sectionId, $title)
{
$requestOptions = [
'section_id' => $sectionId,
'name' => $title,
'title' => $title,
];

return $this->post(UrlBuilder::RESOURCE_EDIT_BOARD_SECTION, $requestOptions);
Expand Down
8 changes: 2 additions & 6 deletions src/Api/Providers/Boards.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public function info($username, $board)
*/
protected function formatBoardName($board)
{
$nameWithRemovedSpaces = str_replace(' ', '-', $board);
return function_exists('mb_strtolower') ? mb_strtolower($nameWithRemovedSpaces) : strtolower($nameWithRemovedSpaces);
$nameWithRemovedSpacesAndSingleQuotes = str_replace([' ', "'"], ['-', ''], $board);
return function_exists('mb_strtolower') ? mb_strtolower($nameWithRemovedSpacesAndSingleQuotes) : strtolower($nameWithRemovedSpacesAndSingleQuotes);
}

/**
Expand Down Expand Up @@ -138,10 +138,6 @@ public function pins($boardId, $limit = Pagination::DEFAULT_LIMIT)
*/
public function update($boardId, $attributes)
{
if (isset($attributes['name'])) {
$attributes['name'] = $this->formatBoardName($attributes['name']);
}

$requestOptions = array_merge(
[
'board_id' => $boardId,
Expand Down
15 changes: 15 additions & 0 deletions tests/Bot/Providers/BoardsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ public function it_formats_a_board_name_with_spaces_when_fetching_its_info()
$this->assertWasGetRequest(UrlBuilder::RESOURCE_GET_BOARD, $request);
}

/** @test */
public function it_formats_a_board_name_with_single_quotes_when_fetching_its_info()
{
$provider = $this->getProvider();

$provider->info('johnDoe', "'my board's name'");

$request = [
'slug' => 'my-boards-name',
'username' => 'johnDoe',
'field_set_key' => 'detailed',
];
$this->assertWasGetRequest(UrlBuilder::RESOURCE_GET_BOARD, $request);
}

/** @test */
public function it_creates_a_public_board()
{
Expand Down