Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
eef37109
Commit
eef37109
authored
Mar 21, 2017
by
Sergio Bertolin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Starting refactoring
parent
2259f7f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
60 deletions
+60
-60
tests/integration/config/behat.yml
tests/integration/config/behat.yml
+0
-2
tests/integration/features/bootstrap/BasicStructure.php
tests/integration/features/bootstrap/BasicStructure.php
+1
-0
tests/integration/features/bootstrap/Comments.php
tests/integration/features/bootstrap/Comments.php
+55
-52
tests/integration/features/comments.feature
tests/integration/features/comments.feature
+4
-6
No files found.
tests/integration/config/behat.yml
View file @
eef37109
...
...
@@ -12,8 +12,6 @@ default:
-
admin
-
admin
regular_user_password
:
123456
-
CommentsContext
:
baseUrl
:
http://localhost:8080
-
TagsContext
:
baseUrl
:
http://localhost:8080
-
CardDavContext
:
...
...
tests/integration/features/bootstrap/BasicStructure.php
View file @
eef37109
...
...
@@ -10,6 +10,7 @@ trait BasicStructure {
use
Auth
;
use
Trashbin
;
use
Checksums
;
use
Comments
;
/** @var string */
private
$currentUser
=
''
;
...
...
tests/integration/features/bootstrap/Comments
Context
.php
→
tests/integration/features/bootstrap/Comments.php
View file @
eef37109
...
...
@@ -21,49 +21,52 @@
require
__DIR__
.
'/../../../../lib/composer/autoload.php'
;
class
CommentsContext
implements
\
Behat\Behat\Context\Context
{
/** @var string */
private
$baseUrl
;
/** @var array */
private
$response
;
//class CommentsContext implements \Behat\Behat\Context\Context {
trait
Comments
{
use
Sharing
;
// /** @var string */
// private $baseUrl;
// /** @var array */
// private $response;
/** @var int */
private
$commentId
;
/** @var int */
private
$fileId
;
/**
* @param string $baseUrl
*/
public
function
__construct
(
$baseUrl
)
{
$this
->
baseUrl
=
$baseUrl
;
//
/**
//
* @param string $baseUrl
//
*/
//
public function __construct($baseUrl) {
//
$this->baseUrl = $baseUrl;
// in case of ci deployment we take the server url from the environment
$testServerUrl
=
getenv
(
'TEST_SERVER_URL'
);
if
(
$testServerUrl
!==
false
)
{
$this
->
baseUrl
=
substr
(
$testServerUrl
,
0
,
-
5
);
}
}
//
// in case of ci deployment we take the server url from the environment
//
$testServerUrl = getenv('TEST_SERVER_URL');
//
if ($testServerUrl !== false) {
//
$this->baseUrl = substr($testServerUrl, 0, -5);
//
}
//
}
/** @AfterScenario */
public
function
teardownScenario
()
{
$client
=
new
\
GuzzleHttp\Client
();
try
{
$client
->
delete
(
$this
->
baseUrl
.
'/remote.php/webdav/myFileToComment.txt'
,
[
'auth'
=>
[
'user0'
,
'123456'
,
],
'headers'
=>
[
'Content-Type'
=>
'application/json'
,
],
]
);
}
catch
(
\
GuzzleHttp\Exception\ClientException
$e
)
{
$e
->
getResponse
();
}
}
//
/** @AfterScenario */
//
public function teardownScenario() {
//
$client = new \GuzzleHttp\Client();
//
try {
//
$client->delete(
//
$this->baseUrl.'/remote.php/webdav/myFileToComment.txt',
//
[
//
'auth' => [
//
'user0',
//
'123456',
//
],
//
'headers' => [
//
'Content-Type' => 'application/json',
//
],
//
]
//
);
//
} catch (\GuzzleHttp\Exception\ClientException $e) {
//
$e->getResponse();
//
}
//
}
/**
* @param string $path
...
...
@@ -175,22 +178,22 @@ class CommentsContext implements \Behat\Behat\Context\Context {
}
}
/**
* @Given As :user sending :verb to :url with
* @param string $user
* @param string $verb
* @param string $url
* @param \Behat\Gherkin\Node\TableNode $body
* @throws \Exception
*/
public
function
asUserSendingToWith
(
$user
,
$verb
,
$url
,
\
Behat\Gherkin\Node\TableNode
$body
)
{
$client
=
new
\
GuzzleHttp\Client
();
$options
=
[];
$options
[
'auth'
]
=
[
$user
,
'123456'
];
$fd
=
$body
->
getRowsHash
();
$options
[
'body'
]
=
$fd
;
$client
->
send
(
$client
->
createRequest
(
$verb
,
$this
->
baseUrl
.
'/ocs/v1.php/'
.
$url
,
$options
));
}
//
/**
//
* @Given As :user sending :verb to :url with
//
* @param string $user
//
* @param string $verb
//
* @param string $url
//
* @param \Behat\Gherkin\Node\TableNode $body
//
* @throws \Exception
//
*/
//
public function asUserSendingToWith($user, $verb, $url, \Behat\Gherkin\Node\TableNode $body) {
//
$client = new \GuzzleHttp\Client();
//
$options = [];
//
$options['auth'] = [$user, '123456'];
//
$fd = $body->getRowsHash();
//
$options['body'] = $fd;
//
$client->send($client->createRequest($verb, $this->baseUrl.'/ocs/v1.php/'.$url, $options));
//
}
/**
* @Then As :user delete the created comment it should return :statusCode
...
...
tests/integration/features/comments.feature
View file @
eef37109
Feature
:
comments
Scenario
:
Creating a comment on a file belonging to myself
Given
user
"user0"
exists
Given
As an
"user0"
...
...
@@ -16,12 +17,9 @@ Feature: comments
Scenario
:
Creating a comment on a shared file belonging to another user
Given
user
"user0"
exists
Given
user
"user1"
exists
Given
User
"user0"
uploads file
"data/textfile.txt"
to
"/myFileToComment.txt"
Given
As
"user0"
sending
"POST"
to
"/apps/files_sharing/api/v1/shares"
with
|
path
|
myFileToComment.txt
|
|
shareWith
|
user1
|
|
shareType
|
0
|
And
user
"user1"
exists
And
User
"user0"
uploads file
"data/textfile.txt"
to
"/myFileToComment.txt"
And
file
"/myFileToComment.txt"
of user
"user0"
is shared with user
"user1"
When
"user1"
posts a comment with content
"A comment from another user"
on the file named
"/myFileToComment.txt"
it should return
"201"
Then
As
"user1"
load all the comments of the file named
"/myFileToComment.txt"
it should return
"207"
And the response should contain a property "oc
:
parentId"
with
value
"0"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment