<commit_before><?php

/*
 * This file is part of the hyn/multi-tenant package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @see https://laravel-tenancy.com
 * @see https://github.com/hyn/multi-tenant
 */

namespace Hyn\Tenancy\Tests\Database;

use Hyn\Tenancy\Database\Connection;
use Hyn\Tenancy\Tests\Test;
use Illuminate\Contracts\Foundation\Application;

class MultiDatabaseTest extends Test
{
    protected function duringSetUp(Application $app)
    {
        // let's configure mysql2
        $config = $app['config']->get('database.connections.mysql', []);
        $config['host'] = 'mysql2';
        $app['config']->set('database.connections.mysql2', $config);

        $this->setUpWebsites();
    }

    public function allow_writing_to_secondary_database()
    {
        $this->website->managed_by_database_connection = 'mysql2';

        $this->assertTrue($this->website->save());

        $this->assertEquals('mysql2', $this->website->managed_by_database_connection);

        // make sure the Website model still uses the regular system name.
        $this->assertEquals(app(Connection::class)->systemName(), $this->website->getConnectionName());<commit_msg>forgot about the phpdoc test<commit_after><?php

/*
 * This file is part of the hyn/multi-tenant package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @see https://laravel-tenancy.com
 * @see https://github.com/hyn/multi-tenant
 */

namespace Hyn\Tenancy\Tests\Database;

use Hyn\Tenancy\Database\Connection;
use Hyn\Tenancy\Tests\Test;
use Illuminate\Contracts\Foundation\Application;

class MultiDatabaseTest extends Test
{
    protected function duringSetUp(Application $app)
    {
        // let's configure mysql2
        $config = $app['config']->get('database.connections.mysql', []);
        $config['host'] = 'mysql2';
        $app['config']->set('database.connections.mysql2', $config);

        $this->setUpWebsites();
    }

    /**
     * @test
     */
    public function allow_writing_to_secondary_database()
    {
        $this->website->managed_by_database_connection = 'mysql2';

        $this->assertTrue($this->website->save());

        $this->assertEquals('mysql2', $this->website->managed_by_database_connection);

        // make sure the Website model still uses the regular system name.
        $this->assertEquals(app(Connection::class)->systemName(), $this->website->getConnectionName());
{'fraction_non_alphanumeric': 0.14291158536585366, 'fraction_numerical': 0.0038109756097560975, 'mean_word_length': 3.597197898423818, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 39, 'https://': 4, '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': '6952926', 'n_tokens_mistral': 769, 'n_tokens_neox': 755, 'n_words': 168}