Updated tests env

This commit is contained in:
eldadfux
2019-09-14 06:41:16 +03:00
parent ddaa9c5b1f
commit 1a73e19233
6 changed files with 157 additions and 5 deletions
+2 -1
View File
@@ -15,8 +15,9 @@ services:
- docker
before_install:
- composer update --ignore-platform-reqs --optimize-autoloader --no-dev --no-plugins --no-scripts
- composer update --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts
- sudo service mysql stop
- cp -r tests/resources/mock/db tests/resources/storage/db
install:
- docker-compose -f tests/resources/docker-compose.yml up -d
+4
View File
@@ -22,6 +22,9 @@
"Template\\": "src/Template"
}
},
"autoload-dev": {
"psr-4": {"Tests\\E2E\\": "tests/e2e"}
},
"require": {
"php": ">=7.3.0",
"ext-curl": "*",
@@ -37,6 +40,7 @@
"appwrite/sdk-generator": "master",
"appwrite/php-clamav": "master",
"appwrite/appwrite": "master",
"utopia-php/framework": "master",
"utopia-php/abuse": "master",
Generated
+36 -1
View File
@@ -4,8 +4,43 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "197b677f995f7b308494e55f1dc66729",
"content-hash": "bcdcb2d9926740fea4a0515f87c58a3c",
"packages": [
{
"name": "appwrite/appwrite",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/appwrite/sdk-for-php.git",
"reference": "c3d6f82565cc5606980451221b8f0a28af6af2f5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/appwrite/sdk-for-php/zipball/c3d6f82565cc5606980451221b8f0a28af6af2f5",
"reference": "c3d6f82565cc5606980451221b8f0a28af6af2f5",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"php": ">=7.1.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.35"
},
"type": "library",
"autoload": {
"psr-4": {
"Appwrite\\": "src/Appwrite"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Appwrite backend as a service cuts up to 70% of the time and costs required for building a modern application. We abstract and simplify common development tasks behind a REST APIs, to help you develop your app in a fast and secure way. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)",
"time": "2019-09-12T16:19:16+00:00"
},
{
"name": "appwrite/php-clamav",
"version": "dev-master",
+1 -1
View File
@@ -10,7 +10,7 @@
>
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
<directory>./tests/e2e/</directory>
</testsuite>
</testsuites>
</phpunit>
+110
View File
@@ -0,0 +1,110 @@
<?php
/**
* Utopia PHP Framework
*
* @package Framework
* @subpackage Tests
*
* @link https://github.com/utopia-php/framework
* @author Eldad Fux <eldad@appwrite.io>
* @version 1.0 RC4
* @license The MIT License (MIT) <http://www.opensource.org/licenses/mit-license.php>
*/
namespace Tests\E2E;
use PHPUnit\Framework\TestCase;
class ViewTest extends TestCase
{
/**
* @var View
*/
protected $view = null;
public function setUp()
{
$this->view = new View(__DIR__ . '/mocks/View/template.phtml');
}
public function tearDown()
{
$this->view = null;
}
public function testSetParam()
{
$value = $this->view->setParam('key', 'value');
// Assertions
$this->assertInstanceOf('Utopia\View', $value);
}
public function testGetParam()
{
$this->view->setParam('key', 'value');
// Assertions
$this->assertEquals('value', $this->view->getParam('key', 'default'));
$this->assertEquals('default', $this->view->getParam('fake', 'default'));
}
public function testSetPath()
{
$value = $this->view->setPath('mocks/View/fake.phtml');
// Assertions
$this->assertInstanceOf('Utopia\View', $value);
}
public function testSetRendered()
{
$this->view->setRendered();
// Assertions
$this->assertEquals(true, $this->view->isRendered());
}
public function testIsRendered()
{
// Assertions
$this->view->setRendered(false);
$this->assertEquals(false, $this->view->isRendered());
// Assertions
$this->view->setRendered(true);
$this->assertEquals(true, $this->view->isRendered());
}
public function testRender()
{
// Assertions
$this->assertEquals('<div>Test template mock</div>', $this->view->render());
$this->view->setRendered();
$this->assertEquals('', $this->view->render());
try {
$this->view->setRendered(false);
$this->view->setPath('just-a-broken-string.phtml');
$this->view->render();
}
catch(\Exception $e) {
return;
}
$this->fail('An expected exception has not been raised.');
}
public function testEscape()
{
// Assertions
$this->assertEquals('&amp;&quot;', $this->view->print('&"', View::FILTER_ESCAPE));
}
public function testNl2p()
{
// Assertions
$this->assertEquals('<p>line1</p><p>line2</p>', $this->view->print("line1\n\nline2", View::FILTER_NL2P));
}
}
+4 -2
View File
@@ -5,6 +5,8 @@ services:
build: ../../
restart: unless-stopped
volumes:
- ./../../:/usr/share/nginx/html
- ./../../docker/nginx.conf:/etc/nginx/nginx.conf:rw
- ./storage:/storage:rw
ports:
- "80:80"
@@ -29,8 +31,8 @@ services:
restart: unless-stopped
environment:
- MYSQL_ROOT_PASSWORD=password
#volumes:
#- ./storage/db:/var/lib/mysql:rw
volumes:
- ./storage/db:/var/lib/mysql:rw
ports:
- 3306:3306/tcp