<commit_before><?php

namespace tests\codeception\unit\models\nerds;

use Yii;
use app\models\UsedItemPhoto;
use yii\codeception\DbTestCase;
use Codeception\Specify;
use app\tests\codeception\unit\fixtures\UsedItemFixture;
use app\tests\codeception\unit\fixtures\UsedItemPhotoFixture;

class UsedItemPhotoTest extends DbTestCase
{
    use Specify;

    public function fixtures()
    {
        return [
            'item'  => UsedItemFixture::className(),
            'photo' => UsedItemPhotoFixture::className(),
        ];
    }

    public function testSave()
    {
        $photoModel = new UsedItemPhoto();

        $this->specify('exception thrown if image name is empty', function () use ($photoModel) {
            $photoModel->save(false);
        }, ['throws' => 'yii\base\Exception']);

        $photoModel->name = 'test';
        $this->specify('exception thrown if item id is empty', function () use ($photoModel) {
            $photoModel->save(false);
        }, ['throws' => 'yii\base\Exception']);

        $photoModel->item_id = $this->item('item_1')->id;
        $this->specify('photo model has been saved successfully', function () use ($photoModel) {
            expect('save is ok', $photoModel->save(false))->true();
        });
    }

    public function testAfterFind()
    {<commit_msg>up UsedItemPhoto test<commit_after><?php

namespace tests\codeception\unit\models\nerds;

use Yii;
use app\models\UsedItemPhoto;
use yii\codeception\DbTestCase;
use Codeception\Specify;
use app\tests\codeception\unit\fixtures\UsedItemFixture;
use app\tests\codeception\unit\fixtures\UsedItemPhotoFixture;

class UsedItemPhotoTest extends DbTestCase
{
    use Specify;

    public function fixtures()
    {
        return [
            'item'  => UsedItemFixture::className(),
            'photo' => UsedItemPhotoFixture::className(),
        ];
    }

    public function testSave()
    {
        $this->specify('image title is empty', function () {
            $photoModel = new UsedItemPhoto();
            $photoModel->save(false);
        }, ['throws' => 'yii\base\Exception']);

        $this->specify('item id for image is empty', function () {
            $photoModel = new UsedItemPhoto();
            $photoModel->name = 'test';
            $photoModel->save(false);
        }, ['throws' => 'yii\base\Exception']);

        $this->specify('set title and item id for image', function () {
            $photoModel = new UsedItemPhoto();
            $photoModel->name = 'test';
            $photoModel->item_id = $this->item('has_photos')->id;
            expect('save success', $photoModel->save(false))->true();
        });
    }

    public function testAfterFind()
    {
{'fraction_non_alphanumeric': 0.1426448736998514, 'fraction_numerical': 0.0003714710252600297, 'mean_word_length': 2.761173184357542, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1369180', 'n_tokens_mistral': 781, 'n_tokens_neox': 766, 'n_words': 162}