mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
70 lines
2.0 KiB
PHP
70 lines
2.0 KiB
PHP
<?php
|
|
|
|
require_once __DIR__ . '/../../../../PhraseanetWebTestCaseAbstract.class.inc';
|
|
|
|
class ControllerPathFileTestTest extends \PhraseanetWebTestCaseAbstract
|
|
{
|
|
|
|
/**
|
|
* As controllers use WebTestCase, it requires a client
|
|
*/
|
|
protected $client;
|
|
|
|
/**
|
|
* If the controller tests require some records, specify it her
|
|
*
|
|
* For example, this will loacd 2 records
|
|
* (self::$record_1 and self::$record_2) :
|
|
*
|
|
* $need_records = 2;
|
|
*
|
|
*/
|
|
protected static $need_records = false;
|
|
|
|
/**
|
|
* The application loader
|
|
*/
|
|
public function createApplication()
|
|
{
|
|
return require __DIR__ . '/../../../../../lib/Alchemy/Phrasea/Application/Admin.php';
|
|
}
|
|
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
$this->client = $this->createClient();
|
|
}
|
|
|
|
/**
|
|
* Default route test
|
|
*/
|
|
public function testRoutePath()
|
|
{
|
|
$file = new \SplFileObject(__DIR__ . '/../../../../testfiles/cestlafete.jpg');
|
|
$this->client->request("GET", "/tests/pathurl/path/", array('path' => $file->getPathname()));
|
|
|
|
$response = $this->client->getResponse();
|
|
$this->assertTrue($response->isOk());
|
|
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
|
|
$content = json_decode($this->client->getResponse()->getContent());
|
|
$this->assertTrue(is_object($content));
|
|
$this->assertObjectHasAttribute('exists', $content);
|
|
$this->assertObjectHasAttribute('file', $content);
|
|
$this->assertObjectHasAttribute('dir', $content);
|
|
$this->assertObjectHasAttribute('readable', $content);
|
|
$this->assertObjectHasAttribute('executable', $content);
|
|
}
|
|
|
|
public function testRouteUrl()
|
|
{
|
|
$this->client->request("GET", "/tests/pathurl/url/", array('url' => "www.google.com"));
|
|
|
|
$response = $this->client->getResponse();
|
|
$this->assertTrue($response->isOk());
|
|
$this->assertEquals("application/json", $this->client->getResponse()->headers->get("content-type"));
|
|
$content = json_decode($this->client->getResponse()->getContent());
|
|
$this->assertTrue(is_object($content));
|
|
}
|
|
|
|
}
|