<commit_before><?php

use Wasp\Test\TestCase,
	Wasp\DI\ServiceMockery;


/**
 * Rest controller mocked tests
 *
 * @package Wasp
 * @subpackage Tests
 * @author <NAME>
 */
class MockedRestControllerTest extends TestCase
{
	
	/**
	 * Set up test env
	 *
	 * @return void
	 * @author <NAME>
	 */
	public function setUp()
	{
		// Mock for database
		$m = new ServiceMockery('database');
		$m->add();

		$mPaginator = new ServiceMockery('paginator');
		$mPaginator->add();

		parent::setUp();

		$this->DI->get('route')->resource('test', '/test', 'Wasp\Test\Entity\Entities\Contact');<commit_msg>Adding more tests for the rest controller<commit_after><?php

use Wasp\Test\TestCase,
	Wasp\DI\ServiceMockery;


/**
 * Rest controller mocked tests
 *
 * @package Wasp
 * @subpackage Tests
 * @author <NAME>
 */
class MockedRestControllerTest extends TestCase
{
	
	/**
	 * Set up test env
	 *
	 * @return void
	 * @author <NAME>
	 */
	public function setUp()
	{
		// Mock for database
		$m = new ServiceMockery('database');
		$m->add();

		$mPaginator = new ServiceMockery('paginator');
		$mPaginator->add();

		parent::setUp();

		$this->DI->get('route')->resource('test', '/test', 'Wasp\Test\Entity\Entities\Contact');
	}

	/**
	 * Test that failure to find an entity is a graceful error
	 *
	 * @return void
	 * @author <NAME>
	 */
	public function test_failToFindEntity()
	{
		$db = $this->DI->get('database');

		$db->shouldReceive('setEntity')->once()->andReturn($db);
		$db->shouldReceive('find')->andThrow(new Exception('Test'));
		
		// Fabricate the request
		$this->DI->get('request')->make('/test/delete/1', 'DELETE', []);
		$response = $this->DI->get('router')->resolve('/test/delete/1');

		$obj = json_decode($response->getContent());

		$this->assertEquals(404, $response->getStatusCode());
{'fraction_non_alphanumeric': 0.18798665183537264, 'fraction_numerical': 0.0027808676307007787, 'mean_word_length': 3.955922865013774, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6806821', 'n_tokens_mistral': 643, 'n_tokens_neox': 589, 'n_words': 127}