Skip to content
Merged
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
Expand Up @@ -25,7 +25,7 @@
},
"autoload-dev": {
"psr-4": {
"chobie\\Tests\\": "tests"
"Tests\\chobie\\": "tests"
}
},
"extra": {
Expand Down
7 changes: 5 additions & 2 deletions src/Jira/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,17 @@ public function getEndpoint()
}

/**
* set end point url.
* Set Endpoint URL
*
* @param $url
* @param string $url
*/
public function setEndPoint($url)
{
$this->fields = array();

// Remove trailing slash in the url
$url = rtrim($url, '/');

$this->endpoint = $url;
}

Expand Down
8 changes: 6 additions & 2 deletions tests/Jira/Api/Authentication/BasicTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<?php

class Jira_Api_Authentication_BasicTest extends PHPUnit_Framework_TestCase
namespace Tests\chobie\Jira;

use chobie\Jira\Api\Authentication\Basic;

class BasicTest extends \PHPUnit_Framework_TestCase
{
public function testBasicAuthentication()
{
$id = "abc";
$pass = "def";

$basic = new \chobie\Jira\Api\Authentication\Basic($id, $pass);
$basic = new Basic($id, $pass);
$this->assertEquals($id, $basic->getId());
$this->assertEquals($pass, $basic->getPassword());
$this->assertEquals(base64_encode(sprintf("%s:%s", $id, $pass)), $basic->getCredential());
Expand Down
28 changes: 28 additions & 0 deletions tests/Jira/ApiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Tests\chobie\Jira;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure these tests are auto-loaded? The namespace for tests in autoload-dev part of composer.json says chobie\\Tests\\ namespace.

Probably need to patch it in there to use Tests\\ chobie\\ instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 7101f7d


use chobie\Jira\Api;
use chobie\Jira\Api\Authentication\Anonymous;

/**
* Class ApiTest
*
* @package Tests\chobie\Jira
*/
class ApiTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests that any trailing slash in the endpoint url is removed before being stored in the object state
*/
public function testSetEndpointTrailingSlash()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're at it please also add a test (not in this method) that shows that url is kept as is when no trailing / is used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 00451d3

{
$api = new Api('https://test.test/', new Anonymous(), null);
$this->assertEquals('https://test.test', $api->getEndpoint());

// Make sure nothing is removed if there is no trailing slash
$url = 'https://urlwithouttrailing.slash';
$api->setEndPoint($url);
$this->assertEquals($url, $api->getEndpoint());
}
}
2 changes: 1 addition & 1 deletion tests/Jira/IssueTypeTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace chobie\Tests\Jira;
namespace Tests\chobie\Jira;

use chobie\Jira\IssueType;

Expand Down