<commit_before><?php namespace Codeception\Module\Drupal7\Submodules;

use Codeception\Util\Shared\Asserts;

/**
 * Class EntityTrait
 * @package Codeception\Module\Drupal7\Submodules
 */
trait EntityTrait
{
    use Asserts;

    /**
     * Grab the output of entity_get_info().
     *
     * @param null $entityType
     *   The entity type, e.g. node, for which the info shall be returned, or NULL to return an array with info about
     *   all types.
     *
     * @return array
     *   Information about an entity type, or all entities if one was passed in.
     */
    public function grabEntityInfo($entityType = null)
    {
        return entity_get_info($entityType);
    }

    /**
     * Check that an entity type exists.
     *
     * @param string $entityMachineName
     *   The machine name of the entity you are testing for (i.e. node)
     */
    public function seeEntityExists($entityMachineName)
    {
        $entity = $this->grabEntityInfo($entityMachineName);

        $this->assertNotNull($entity);
    }

    /**
     * Check that an entity type does not exist.
     *
     * @param string $entityMachineName
     *   The machine name of the entity you are testing for (i.e. node)
     */
    public function dontSeeEntityExists($entityMachineName)
    {
        $entity = $this->grabEntityInfo($entityMachineName);

        $this->assertNull($entity);
    }

    /**
     * Check that an entity type has a specific bundle.
     *
     * @param $entityMachineName
     *    The machine name of the entity you are testing (i.e. node)
     * @param $bundleMachineName
     *    The machine name of the bundle you are testing for (i.e. article)
     */
    public function seeEntityHasBundle($entityMachineName, $bundleMachineName)
    {
        $entityInfo = $this->grabEntityInfo($entityMachineName);

        if (!array_key_exists($bundleMachineName, $entityInfo['bundles'])) {
            $this->fail('Bundle ' . $bundleMachineName . ' does not exist on the ' . $entityMachineName . ' entity.');
        }
    }

    /**
     * Check that an entity type does not have a specific bundle.
     *
     * @param $entityMachineName
     *    The machine name of the entity you are testing (i.e. node)
     * @param $bundleMachineName
     *    The machine name of the bundle you are testing for (i.e. article)
     */
    public function dontSeeEntityHasBundle($entityMachineName, $bundleMachineName)
    {
        $entityInfo = $this->grabEntityInfo($entityMachineName);

        if (array_key_exists($bundleMachineName, $entityInfo['bundles'])) {
            $this->fail('Bundle ' . $bundleMachineName . ' exists on the ' . $entityMachineName . ' entity.');
        }
    }
}<commit_msg>Added return statements to ensure code coverage.<commit_after><?php namespace Codeception\Module\Drupal7\Submodules;

use Codeception\Util\Shared\Asserts;

/**
 * Class EntityTrait
 * @package Codeception\Module\Drupal7\Submodules
 */
trait EntityTrait
{
    use Asserts;

    /**
     * Grab the output of entity_get_info().
     *
     * @param null $entityType
     *   The entity type, e.g. node, for which the info shall be returned, or NULL to return an array with info about
     *   all types.
     *
     * @return array
     *   Information about an entity type, or all entities if one was passed in.
     */
    public function grabEntityInfo($entityType = null)
    {
        return entity_get_info($entityType);
    }

    /**
     * Check that an entity type exists.
     *
     * @param string $entityMachineName
     *   The machine name of the entity you are testing for (i.e. node)
     */
    public function seeEntityExists($entityMachineName)
    {
        $entity = $this->grabEntityInfo($entityMachineName);

        $this->assertNotNull($entity);
    }

    /**
     * Check that an entity type does not exist.
     *
     * @param string $entityMachineName
     *   The machine name of the entity you are testing for (i.e. node)
     */
    public function dontSeeEntityExists($entityMachineName)
    {
        $entity = $this->grabEntityInfo($entityMachineName);

        $this->assertNull($entity);
    }

    /**
     * Check that an entity type has a specific bundle.
     *
     * @param $entityMachineName
     *    The machine name of the entity you are testing (i.e. node)
     * @param $bundleMachineName
     *    The machine name of the bundle you are testing for (i.e. article)
     */
    public function seeEntityHasBundle($entityMachineName, $bundleMachineName)
    {
        $entityInfo = $this->grabEntityInfo($entityMachineName);

        if (array_key_exists($bundleMachineName, $entityInfo['bundles'])) {
            return true;
        }

        $failMessage = 'Bundle ' . $bundleMachineName . ' does not exist on the ' . $entityMachineName . ' entity.';

        return $this->fail($failMessage);
    }

    /**
     * Check that an entity type does not have a specific bundle.
     *
     * @param $entityMachineName
     *    The machine name of the entity you are testing (i.e. node)
     * @param $bundleMachineName
     *    The machine name of the bundle you are testing for (i.e. article)
     */
    public function dontSeeEntityHasBundle($entityMachineName, $bundleMachineName)
    {
        $entityInfo = $this->grabEntityInfo($entityMachineName);

        if (!array_key_exists($bundleMachineName, $entityInfo['bundles'])) {
            return true;
        }

        $failMessage = 'Bundle ' . $bundleMachineName . ' exists on the ' . $entityMachineName . ' entity.';

        return $this->fail($failMessage);
    }
}
{'fraction_non_alphanumeric': 0.10320157395814702, 'fraction_numerical': 0.0007154355213736362, 'mean_word_length': 2.5303030303030303, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '2131463', 'n_tokens_mistral': 1575, 'n_tokens_neox': 1557, 'n_words': 474}