-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from palantirnet/file-context
Add methods to create Drupal files.
- Loading branch information
Showing
3 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/Palantirnet/PalantirBehatExtension/Context/DrupalFileContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* @file | ||
* Behat context class with additional file-related steps. | ||
* | ||
* @copyright (c) Copyright 2015 Palantir.net, Inc. | ||
*/ | ||
|
||
namespace Palantirnet\PalantirBehatExtension\Context; | ||
|
||
use Behat\Gherkin\Node\TableNode; | ||
|
||
class DrupalFileContext extends SharedDrupalContext | ||
{ | ||
|
||
/** | ||
* @Given the file :filename | ||
*/ | ||
public function createFile($filename, $status = 1) | ||
{ | ||
$file = (object) array( | ||
'filename' => $filename, | ||
'status' => $status, | ||
); | ||
|
||
$file = $this->expandFile($file); | ||
|
||
$this->fileCreate($file); | ||
} | ||
|
||
/** | ||
* @Given files: | ||
* | ||
* Given files: | ||
* | filename | status | author | | ||
* | example.pdf | 1 | Somebody | | ||
* | test.png | 0 | Admin | | ||
* | ... | ... | ... | | ||
*/ | ||
public function createFiles(TableNode $filesTable) | ||
{ | ||
foreach ($filesTable->getHash() as $fileHash) { | ||
$file = (object) $fileHash; | ||
$file = $this->expandFile($file); | ||
|
||
$this->fileCreate($file); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters