Skip to content

Commit

Permalink
Fixed tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
feuzeu committed Jan 9, 2025
1 parent 0cee1e9 commit 2546345
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 181 deletions.
2 changes: 1 addition & 1 deletion tests/TestRegistrationApp/RegistrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function testJaxonClassAnnotations()
});

$this->assertTrue(jaxon()->app()->canProcessRequest());
$this->assertNotNull(jaxon()->di()->getCallableClassPlugin()->processRequest());
jaxon()->di()->getCallableClassPlugin()->processRequest();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestRequestHandler/ClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testGetRequestToJaxonClass()
$this->assertFalse(jaxon()->di()->getCallableFunctionPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertTrue(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertNotNull(jaxon()->di()->getCallableClassPlugin()->processRequest());
jaxon()->di()->getCallableClassPlugin()->processRequest();
}

/**
Expand All @@ -80,7 +80,7 @@ public function testPostRequestToJaxonClass()
$this->assertFalse(jaxon()->di()->getCallableFunctionPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertTrue(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertNotNull(jaxon()->di()->getCallableClassPlugin()->processRequest());
jaxon()->di()->getCallableClassPlugin()->processRequest();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestRequestHandler/DirectoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testGetRequestToJaxonClass()

$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableClassPlugin()->processRequest());
jaxon()->di()->getCallableClassPlugin()->processRequest();
}

/**
Expand All @@ -89,7 +89,7 @@ public function testPostRequestToJaxonClass()

$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableClassPlugin()->processRequest());
jaxon()->di()->getCallableClassPlugin()->processRequest();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/TestRequestHandler/FunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testGetRequestToJaxonFunction()
$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableFunctionPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertFalse(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableFunctionPlugin()->processRequest());
jaxon()->di()->getCallableFunctionPlugin()->processRequest();
$this->assertCount(1, jaxon()->getResponse()->getCommands());
}

Expand All @@ -88,7 +88,7 @@ public function testPostRequestToJaxonFunction()
$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableFunctionPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertFalse(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableFunctionPlugin()->processRequest());
jaxon()->di()->getCallableFunctionPlugin()->processRequest();
$this->assertCount(1, jaxon()->getResponse()->getCommands());
}

Expand Down Expand Up @@ -138,7 +138,7 @@ public function testRequestToJaxonFunction()

$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableFunctionPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableFunctionPlugin()->processRequest());
jaxon()->di()->getCallableFunctionPlugin()->processRequest();

$xTarget = jaxon()->di()->getCallableFunctionPlugin()->getTarget();
$this->assertNotNull($xTarget);
Expand Down Expand Up @@ -170,7 +170,7 @@ public function testRequestToJaxonClass()

$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableFunctionPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableFunctionPlugin()->processRequest());
jaxon()->di()->getCallableFunctionPlugin()->processRequest();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/TestRequestHandler/NamespaceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function testGetRequestToJaxonClass()

$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableClassPlugin()->processRequest());
jaxon()->di()->getCallableClassPlugin()->processRequest();
}

/**
Expand All @@ -81,7 +81,7 @@ public function testPostRequestToJaxonClass()

$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest());
$this->assertTrue(jaxon()->di()->getCallableClassPlugin()->canProcessRequest(jaxon()->di()->getRequest()));
$this->assertNotNull(jaxon()->di()->getCallableClassPlugin()->processRequest());
jaxon()->di()->getCallableClassPlugin()->processRequest();
}

/**
Expand Down
7 changes: 2 additions & 5 deletions tests/src/dir/ClassA.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?php

use Jaxon\Response\Response;
use function Jaxon\jaxon;

class ClassA
{
public function methodAa(): Response
public function methodAa()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}

public function methodAb(): Response
public function methodAb()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}
}
7 changes: 2 additions & 5 deletions tests/src/dir/ClassB.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
<?php

use Jaxon\Response\Response;
use function Jaxon\jaxon;

class ClassB
{
public function methodBa(): Response
public function methodBa()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}

public function methodBb(): Response
public function methodBb()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}
}
9 changes: 3 additions & 6 deletions tests/src/dir/ClassC.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@

class ClassC
{
public function methodCa(): Response
public function methodCa()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}

public function methodCb(): Response
public function methodCb()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}

public function methodCc(): Response
public function methodCc()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}
}
4 changes: 1 addition & 3 deletions tests/src/dir/ClassD.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
<?php

use Jaxon\Response\Response;
use function Jaxon\jaxon;

class ClassD
{
public function methodDa(): Response
public function methodDa()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}
}
7 changes: 2 additions & 5 deletions tests/src/dir_ns/DirA/ClassA.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@

namespace Jaxon\NsTests\DirA;

use Jaxon\Response\Response;
use function Jaxon\jaxon;

class ClassA
{
public function methodAa(): Response
public function methodAa()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}

public function methodAb(): Response
public function methodAb()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}
}
8 changes: 2 additions & 6 deletions tests/src/dir_ns/DirB/ClassB.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,23 @@

namespace Jaxon\NsTests\DirB;

use Jaxon\Response\Response;
use Jaxon\Tests\Ns\Lib\ServiceInterface;
use function Jaxon\jaxon;

class ClassB
{
/**
* @di('attr' => 'service', 'class' => 'ServiceInterface')
* @return Response
*/
public function methodBa(): Response
public function methodBa()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}

public function methodBb(): Response
public function methodBb()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}
}
7 changes: 2 additions & 5 deletions tests/src/dir_ns/DirC/ClassC.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,23 @@
use Jaxon\App\CallableClass;
use Jaxon\Exception\SetupException;
use Jaxon\NsTests\DirB\ClassB;
use Jaxon\Response\Response;
use function Jaxon\jaxon;

class ClassC extends CallableClass
{
/**
* @throws SetupException
*/
public function methodCa(): Response
public function methodCa()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
$this->cl(ClassB::class)->methodBb();
return $xResponse;
}

public function methodCb(): Response
public function methodCb()
{
$xResponse = jaxon()->getResponse();
$xResponse->html('div', 'This is the div content!!');
return $xResponse;
}
}
4 changes: 1 addition & 3 deletions tests/src/first.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php

use Jaxon\Response\Response;
use function Jaxon\jaxon;

function my_first_function(): Response
function my_first_function()
{
$xResponse = jaxon()->getResponse();
$xResponse->alert('This is a response!!');
return $xResponse;
}
4 changes: 1 addition & 3 deletions tests/src/packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

use Jaxon\App\CallableClass;
use Jaxon\Plugin\AbstractPackage;
use Jaxon\Response\Response;

class SamplePackageClass extends CallableClass
{
public function home(): Response
public function home()
{
$this->response->debug('This class is registered by a package!!');
return $this->response;
}
}

Expand Down
12 changes: 3 additions & 9 deletions tests/src/response/Misc.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
<?php

use Jaxon\App\CallableClass;
use Jaxon\Response\Response;
use function Jaxon\jaxon;

class Misc extends CallableClass
{
public function simple(): Response
public function simple()
{
$this->response->alert('This is the global response!');
$aCommands = $this->response->getCommands();
$aCommands[0]->setOption('name', 'value');
return $this->response;
}

public function merge(): Response
public function merge()
{
$this->response->alert('This is the global response!');

$xResponse = jaxon()->newResponse();
$xResponse->debug('This is a different response!');
return $xResponse;
}

public function appendbefore(): Response
public function appendbefore()
{
$this->response->alert('This is the global response!');
$xResponse = jaxon()->newResponse();
$xResponse->debug('This is a different response!');
// Merge responses. No need. In v5, the commands are automatically merged.
// $this->response->appendResponse($xResponse, true);
return $this->response;
}
}
6 changes: 2 additions & 4 deletions tests/src/response/TestCb.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<?php

use Jaxon\App\CallableClass;
use Jaxon\Response\Response;

class TestCb extends CallableClass
{
public function simple(): Response
public function simple()
{
$this->response->alert('This is the global response!');
return $this->response;
}

/**
* @throws Exception
*/
public function error(): Response
public function error()
{
throw new Exception('This method throws an exception!');
}
Expand Down
10 changes: 3 additions & 7 deletions tests/src/response/TestDataBag.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
<?php

use Jaxon\App\CallableClass;
use Jaxon\Response\Response;

class TestDataBag extends CallableClass
{
public function getValue(): Response
public function getValue()
{
$sValue = $this->response->bag('dataset')->get('key', 'Default value');
$this->response->html('div-id', $sValue);
return $this->response;
}

public function setValue(): Response
public function setValue()
{
$this->response->bag('dataset')->set('key', 'value');
return $this->response;
}

public function updateValue(): Response
public function updateValue()
{
$this->response->bag('dataset')->set('key2', 'value2');
$sValue = $this->response->bag('dataset')->get('key1', 'Default value');
$this->response->html('div-id', $sValue);
return $this->response;
}
}
Loading

0 comments on commit 2546345

Please sign in to comment.