Skip to content

Commit

Permalink
twig update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagepard committed Jun 19, 2018
1 parent c99d109 commit 3a70598
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions tests/ControllerTest.php
Expand Up @@ -53,8 +53,8 @@ protected function setUp(): void

$this->container = Container::app();
$this->container->setConfig([
'bp' => dirname(__DIR__) . '/',
'env' => 'development',
'bp' => dirname(__DIR__) . '/',
'env' => 'development',
]);

$this->container->setBinding(ContainerInterface::class, Container::$app);
Expand All @@ -74,46 +74,46 @@ protected function setUp(): void
*/
public function testInit()
{
$this->assertInstanceOf(ContainerInterface::class, $this->controller()->container());
$this->assertTrue($this->container()->hasSession('csrf_token'));
$this->controller()->csrfProtection();
$this->assertInstanceOf(ContainerInterface::class, $this->controller->container());
$this->assertTrue($this->container->hasSession('csrf_token'));
$this->controller->csrfProtection();
}

/**
* @runInSeparateProcess
*/
public function testView()
{
$this->assertEquals('"Hello World!!!"', $this->controller()->view('index', ['title' => 'title']));
$this->assertEquals('"Hello World!!!"', $this->controller->view('index', ['title' => 'title']));
}

/**
* @runInSeparateProcess
*/
public function testTwig()
{
$this->assertNull($this->controller()->twig('index.html.twig', ['title' => 'title']));
$this->assertNull($this->controller->twig('index', ['title' => 'title']));
}

/**
* @runInSeparateProcess
*/
public function testData()
{
$this->controller()->setData([
$this->controller->setData([
'first' => 'one',
]
);

$this->controller()->setData('two', 'second');
$this->controller()->addData(['first' => 'one'], 'array');
$this->controller()->addData(['two' => 'second']);
$this->assertEquals('one', $this->controller()->data('first'));
$this->assertEquals('two', $this->controller()->data('second'));
$this->assertArrayHasKey('first', $this->controller()->data());
$this->assertTrue($this->controller()->hasData('first'));
$this->assertTrue($this->controller()->hasData('second'));
$this->assertTrue($this->controller()->hasData('array', 'first'));
$this->controller->setData('two', 'second');
$this->controller->addData(['first' => 'one'], 'array');
$this->controller->addData(['two' => 'second']);
$this->assertEquals('one', $this->controller->data('first'));
$this->assertEquals('two', $this->controller->data('second'));
$this->assertArrayHasKey('first', $this->controller->data());
$this->assertTrue($this->controller->hasData('first'));
$this->assertTrue($this->controller->hasData('second'));
$this->assertTrue($this->controller->hasData('array', 'first'));
}

/**
Expand All @@ -122,24 +122,8 @@ public function testData()
public function testFileUpload()
{
define('APP_URL', 'http://example.com');
$this->controller()->fileUpload('img', $this->container->config('bp') . 'app/storage');
$this->assertTrue($this->container()->isUploaded('img'));
$this->assertEquals($this->container()->getPost('image'), $this->controller()->fileUpload('image', $this->container->config('bp') . 'app/storage'));
}

/**
* @return ControllerInterface
*/
public function controller(): ControllerInterface
{
return $this->controller;
}

/**
* @return ContainerInterface
*/
public function container(): ContainerInterface
{
return $this->container;
$this->controller->fileUpload('img', $this->container->config('bp') . 'app/storage');
$this->assertTrue($this->container->isUploaded('img'));
$this->assertEquals($this->container->getPost('image'), $this->controller->fileUpload('image', $this->container->config('bp') . 'app/storage'));
}
}

0 comments on commit 3a70598

Please sign in to comment.